aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AutoComplete.cxx19
-rw-r--r--src/AutoComplete.h14
-rw-r--r--src/CallTip.cxx18
-rw-r--r--src/CallTip.h6
-rw-r--r--src/CaseConvert.cxx4
-rw-r--r--src/CaseConvert.h2
-rw-r--r--src/CaseFolder.cxx2
-rw-r--r--src/CaseFolder.h2
-rw-r--r--src/CellBuffer.cxx109
-rw-r--r--src/CellBuffer.h18
-rw-r--r--src/CharClassify.cxx2
-rw-r--r--src/CharClassify.h2
-rw-r--r--src/CharacterCategoryMap.cxx2
-rw-r--r--src/CharacterCategoryMap.h2
-rw-r--r--src/CharacterType.cxx4
-rw-r--r--src/CharacterType.h2
-rw-r--r--src/ContractionState.cxx4
-rw-r--r--src/ContractionState.h2
-rw-r--r--src/DBCS.cxx4
-rw-r--r--src/DBCS.h2
-rw-r--r--src/Debugging.h4
-rw-r--r--src/Decoration.cxx11
-rw-r--r--src/Decoration.h2
-rw-r--r--src/Document.cxx309
-rw-r--r--src/Document.h79
-rw-r--r--src/EditModel.cxx30
-rw-r--r--src/EditModel.h11
-rw-r--r--src/EditView.cxx341
-rw-r--r--src/EditView.h11
-rw-r--r--src/Editor.cxx3110
-rw-r--r--src/Editor.h177
-rw-r--r--src/ElapsedPeriod.h2
-rw-r--r--src/FontQuality.h14
-rw-r--r--src/Geometry.cxx2
-rw-r--r--src/Geometry.h8
-rw-r--r--src/Indicator.cxx66
-rw-r--r--src/Indicator.h22
-rw-r--r--src/KeyMap.cxx200
-rw-r--r--src/KeyMap.h38
-rw-r--r--src/LineMarker.cxx96
-rw-r--r--src/LineMarker.h14
-rw-r--r--src/MarginView.cxx142
-rw-r--r--src/MarginView.h2
-rw-r--r--src/Partitioning.h2
-rw-r--r--src/PerLine.cxx17
-rw-r--r--src/PerLine.h2
-rw-r--r--src/Platform.h24
-rw-r--r--src/PositionCache.cxx36
-rw-r--r--src/PositionCache.h14
-rw-r--r--src/RESearch.cxx2
-rw-r--r--src/RESearch.h2
-rw-r--r--src/RunStyles.cxx11
-rw-r--r--src/RunStyles.h2
-rw-r--r--src/ScintillaBase.cxx341
-rw-r--r--src/ScintillaBase.h20
-rw-r--r--src/Selection.cxx4
-rw-r--r--src/Selection.h2
-rw-r--r--src/SparseVector.h2
-rw-r--r--src/SplitVector.h2
-rw-r--r--src/Style.cxx20
-rw-r--r--src/Style.h20
-rw-r--r--src/UniConversion.cxx4
-rw-r--r--src/UniConversion.h2
-rw-r--r--src/UniqueString.cxx2
-rw-r--r--src/UniqueString.h2
-rw-r--r--src/ViewStyle.cxx269
-rw-r--r--src/ViewStyle.h102
-rw-r--r--src/XPM.cxx3
-rw-r--r--src/XPM.h2
69 files changed, 2932 insertions, 2888 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index 3de456371..1447939b7 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -19,16 +19,19 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
#include "CharacterType.h"
#include "Position.h"
#include "AutoComplete.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
AutoComplete::AutoComplete() :
active(false),
@@ -41,10 +44,10 @@ AutoComplete::AutoComplete() :
cancelAtStartPos(true),
autoHide(true),
dropRestOfWord(false),
- ignoreCaseBehaviour(SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE),
+ ignoreCaseBehaviour(CaseInsensitiveBehaviour::RespectCase),
widthLBDefault(100),
heightLBDefault(100),
- autoSort(SC_ORDER_PRESORTED) {
+ autoSort(Ordering::PreSorted) {
lb = ListBox::Allocate();
}
@@ -60,7 +63,7 @@ bool AutoComplete::Active() const noexcept {
void AutoComplete::Start(Window &parent, int ctrlID,
Sci::Position position, Point location, Sci::Position startLen_,
- int lineHeight, bool unicodeMode, int technology) {
+ int lineHeight, bool unicodeMode, Technology technology) {
if (active) {
Cancel();
}
@@ -147,7 +150,7 @@ struct Sorter {
};
void AutoComplete::SetList(const char *list) {
- if (autoSort == SC_ORDER_PRESORTED) {
+ if (autoSort == Ordering::PreSorted) {
lb->SetList(list, separator, typesep);
sortMatrix.clear();
for (int i = 0; i < lb->Length(); ++i)
@@ -160,7 +163,7 @@ void AutoComplete::SetList(const char *list) {
for (int i = 0; i < static_cast<int>(IndexSort.indices.size()) / 2; ++i)
sortMatrix.push_back(i);
std::sort(sortMatrix.begin(), sortMatrix.end(), IndexSort);
- if (autoSort == SC_ORDER_CUSTOM || sortMatrix.size() < 2) {
+ if (autoSort == Ordering::Custom || sortMatrix.size() < 2) {
lb->SetList(list, separator, typesep);
PLATFORM_ASSERT(lb->Length() == static_cast<int>(sortMatrix.size()));
return;
@@ -253,7 +256,7 @@ void AutoComplete::Select(const char *word) {
}
location = pivot;
if (ignoreCase
- && ignoreCaseBehaviour == SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE) {
+ && ignoreCaseBehaviour == CaseInsensitiveBehaviour::RespectCase) {
// Check for exact-case match
for (; pivot <= end; pivot++) {
item = lb->GetValue(sortMatrix[pivot]);
@@ -277,7 +280,7 @@ void AutoComplete::Select(const char *word) {
else
lb->Select(-1);
} else {
- if (autoSort == SC_ORDER_CUSTOM) {
+ if (autoSort == Ordering::Custom) {
// Check for a logically earlier match
for (int i = location + 1; i <= end; ++i) {
std::string item = lb->GetValue(sortMatrix[i]);
diff --git a/src/AutoComplete.h b/src/AutoComplete.h
index c5b40ad14..c46530771 100644
--- a/src/AutoComplete.h
+++ b/src/AutoComplete.h
@@ -8,7 +8,7 @@
#ifndef AUTOCOMPLETE_H
#define AUTOCOMPLETE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
*/
@@ -32,14 +32,14 @@ public:
bool cancelAtStartPos;
bool autoHide;
bool dropRestOfWord;
- unsigned int ignoreCaseBehaviour;
+ Scintilla::CaseInsensitiveBehaviour ignoreCaseBehaviour;
int widthLBDefault;
int heightLBDefault;
- /** SC_ORDER_PRESORTED: Assume the list is presorted; selection will fail if it is not alphabetical<br />
- * SC_ORDER_PERFORMSORT: Sort the list alphabetically; start up performance cost for sorting<br />
- * SC_ORDER_CUSTOM: Handle non-alphabetical entries; start up performance cost for generating a sorted lookup table
+ /** Ordering::PreSorted: Assume the list is presorted; selection will fail if it is not alphabetical<br />
+ * Ordering::PerformSort: Sort the list alphabetically; start up performance cost for sorting<br />
+ * Ordering::Custom: Handle non-alphabetical entries; start up performance cost for generating a sorted lookup table
*/
- int autoSort;
+ Scintilla::Ordering autoSort;
AutoComplete();
~AutoComplete();
@@ -49,7 +49,7 @@ public:
/// Display the auto completion list positioned to be near a character position
void Start(Window &parent, int ctrlID, Sci::Position position, Point location,
- Sci::Position startLen_, int lineHeight, bool unicodeMode, int technology);
+ Sci::Position startLen_, int lineHeight, bool unicodeMode, Scintilla::Technology technology);
/// The stop chars are characters which, when typed, cause the auto completion list to disappear
void SetStopChars(const char *stopChars_);
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 8229fc82c..18caddea1 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -20,16 +20,18 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
-
#include "Position.h"
#include "CallTip.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
size_t Chunk::Length() const noexcept {
return end - start;
@@ -93,7 +95,7 @@ constexpr bool IsArrowCharacter(char ch) noexcept {
return (ch == 0) || (ch == '\001') || (ch == '\002');
}
-void DrawArrow(Scintilla::Surface *surface, const PRectangle &rc, bool upArrow, ColourRGBA colourBG, ColourRGBA colourUnSel) {
+void DrawArrow(Surface *surface, const PRectangle &rc, bool upArrow, ColourRGBA colourBG, ColourRGBA colourUnSel) {
surface->FillRectangle(rc, colourBG);
const PRectangle rcClientInner = Clamp(rc.Inset(1), Edge::right, rc.right - 2);
surface->FillRectangle(rcClientInner, colourUnSel);
@@ -271,8 +273,8 @@ void CallTip::MouseClick(Point pt) noexcept {
PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
const char *faceName, int size,
- int codePage_, int characterSet,
- int technology,
+ int codePage_, CharacterSet characterSet,
+ Technology technology,
const char *localeName,
const Window &wParent) {
clickPlace = 0;
@@ -285,8 +287,8 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co
inCallTipMode = true;
posStartCallTip = pos;
const XYPOSITION deviceHeight = static_cast<XYPOSITION>(surfaceMeasure->DeviceHeightFont(size));
- const FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL,
- false, 0, technology, characterSet, localeName);
+ const FontParameters fp(faceName, deviceHeight / FontSizeMultiplier, FontWeight::Normal,
+ false, FontQuality::QualityDefault, technology, characterSet, localeName);
font = Font::Allocate(fp);
// Look for multiple lines in the text
// Only support \n here - simply means container must avoid \r!
@@ -330,7 +332,7 @@ void CallTip::SetHighlight(size_t start, size_t end) {
}
// Set the tab size (sizes > 0 enable the use of tabs). This also enables the
-// use of the STYLE_CALLTIP.
+// use of the StyleCallTip.
void CallTip::SetTabSize(int tabSz) noexcept {
tabSize = tabSz;
useStyleCallTip = true;
diff --git a/src/CallTip.h b/src/CallTip.h
index 998bdabf5..f2889d44a 100644
--- a/src/CallTip.h
+++ b/src/CallTip.h
@@ -8,7 +8,7 @@
#ifndef CALLTIP_H
#define CALLTIP_H
-namespace Scintilla {
+namespace Scintilla::Internal {
struct Chunk {
size_t start;
@@ -30,7 +30,7 @@ class CallTip {
int lineHeight; // vertical line spacing
int offsetMain; // The alignment point of the call tip
int tabSize; // Tab size in pixels, <=0 no TAB expand
- bool useStyleCallTip; // if true, STYLE_CALLTIP should be used
+ bool useStyleCallTip; // if true, StyleCallTip should be used
bool above; // if true, display calltip above text
int DrawChunk(Surface *surface, int x, std::string_view sv,
@@ -72,7 +72,7 @@ public:
/// Setup the calltip and return a rectangle of the area required.
PRectangle CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
const char *faceName, int size, int codePage_,
- int characterSet, int technology, const char *localeName,
+ Scintilla::CharacterSet characterSet, Scintilla::Technology technology, const char *localeName,
const Window &wParent);
void CallTipCancel();
diff --git a/src/CaseConvert.cxx b/src/CaseConvert.cxx
index ff5ad5b10..03dbce4e9 100644
--- a/src/CaseConvert.cxx
+++ b/src/CaseConvert.cxx
@@ -20,7 +20,7 @@
#include "CaseConvert.h"
#include "UniConversion.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
namespace {
// Use an unnamed namespace to protect the declarations from name conflicts
@@ -795,7 +795,7 @@ CaseConverter *ConverterForConversion(CaseConversion conversion) noexcept {
}
-namespace Scintilla {
+namespace Scintilla::Internal {
ICaseConverter *ConverterFor(CaseConversion conversion) {
CaseConverter *pCaseConv = ConverterForConversion(conversion);
diff --git a/src/CaseConvert.h b/src/CaseConvert.h
index c5f217d09..ca45f175a 100644
--- a/src/CaseConvert.h
+++ b/src/CaseConvert.h
@@ -10,7 +10,7 @@
#ifndef CASECONVERT_H
#define CASECONVERT_H
-namespace Scintilla {
+namespace Scintilla::Internal {
enum class CaseConversion {
fold,
diff --git a/src/CaseFolder.cxx b/src/CaseFolder.cxx
index d093829ba..47f319504 100644
--- a/src/CaseFolder.cxx
+++ b/src/CaseFolder.cxx
@@ -12,7 +12,7 @@
#include "CaseFolder.h"
#include "CaseConvert.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
CaseFolder::~CaseFolder() {
}
diff --git a/src/CaseFolder.h b/src/CaseFolder.h
index 966069bc4..1169f9bd7 100644
--- a/src/CaseFolder.h
+++ b/src/CaseFolder.h
@@ -8,7 +8,7 @@
#ifndef CASEFOLDER_H
#define CASEFOLDER_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class CaseFolder {
public:
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index 84c2c27a7..375fe2201 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -20,16 +20,17 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
-#include "Scintilla.h"
#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "CellBuffer.h"
#include "UniConversion.h"
-namespace Scintilla {
+namespace Scintilla::Internal {
struct CountWidths {
// Measures the number of characters in a string divided into those
@@ -74,17 +75,18 @@ public:
virtual Sci::Position LineStart(Sci::Line line) const noexcept = 0;
virtual void InsertCharacters(Sci::Line line, CountWidths delta) noexcept = 0;
virtual void SetLineCharactersWidth(Sci::Line line, CountWidths width) noexcept = 0;
- virtual int LineCharacterIndex() const noexcept = 0;
- virtual bool AllocateLineCharacterIndex(int lineCharacterIndex, Sci::Line lines) = 0;
- virtual bool ReleaseLineCharacterIndex(int lineCharacterIndex) = 0;
- virtual Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept = 0;
- virtual Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept = 0;
+ virtual Scintilla::LineCharacterIndexType LineCharacterIndex() const noexcept = 0;
+ virtual bool AllocateLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex, Sci::Line lines) = 0;
+ virtual bool ReleaseLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex) = 0;
+ virtual Sci::Position IndexLineStart(Sci::Line line, Scintilla::LineCharacterIndexType lineCharacterIndex) const noexcept = 0;
+ virtual Sci::Line LineFromPositionIndex(Sci::Position pos, Scintilla::LineCharacterIndexType lineCharacterIndex) const noexcept = 0;
virtual ~ILineVector() {}
};
}
using namespace Scintilla;
+using namespace Scintilla::Internal;
template <typename POS>
class LineStartIndex {
@@ -147,15 +149,16 @@ class LineVector : public ILineVector {
PerLine *perLine;
LineStartIndex<POS> startsUTF16;
LineStartIndex<POS> startsUTF32;
- int activeIndices;
+ LineCharacterIndexType activeIndices;
void SetActiveIndices() noexcept {
- activeIndices = (startsUTF32.Active() ? SC_LINECHARACTERINDEX_UTF32 : 0)
- | (startsUTF16.Active() ? SC_LINECHARACTERINDEX_UTF16 : 0);
+ activeIndices =
+ (startsUTF32.Active() ? LineCharacterIndexType::Utf32 : LineCharacterIndexType::None)
+ | (startsUTF16.Active() ? LineCharacterIndexType::Utf16 : LineCharacterIndexType::None);
}
public:
- LineVector() : starts(256), perLine(nullptr), activeIndices(0) {
+ LineVector() : starts(256), perLine(nullptr), activeIndices(LineCharacterIndexType::None) {
}
// Deleted so LineVector objects can not be copied.
LineVector(const LineVector &) = delete;
@@ -181,11 +184,11 @@ public:
void InsertLine(Sci::Line line, Sci::Position position, bool lineStart) override {
const POS lineAsPos = static_cast<POS>(line);
starts.InsertPartition(lineAsPos, static_cast<POS>(position));
- if (activeIndices) {
- if (activeIndices & SC_LINECHARACTERINDEX_UTF32) {
+ if (activeIndices != LineCharacterIndexType::None) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf32)) {
startsUTF32.InsertLines(line, 1);
}
- if (activeIndices & SC_LINECHARACTERINDEX_UTF16) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
startsUTF16.InsertLines(line, 1);
}
}
@@ -202,11 +205,11 @@ public:
} else {
starts.InsertPartitionsWithCast(lineAsPos, positions, lines);
}
- if (activeIndices) {
- if (activeIndices & SC_LINECHARACTERINDEX_UTF32) {
+ if (activeIndices != LineCharacterIndexType::None) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf32)) {
startsUTF32.InsertLines(line, lines);
}
- if (activeIndices & SC_LINECHARACTERINDEX_UTF16) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
startsUTF16.InsertLines(line, lines);
}
}
@@ -221,10 +224,10 @@ public:
}
void RemoveLine(Sci::Line line) override {
starts.RemovePartition(static_cast<POS>(line));
- if (activeIndices & SC_LINECHARACTERINDEX_UTF32) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf32)) {
startsUTF32.starts.RemovePartition(static_cast<POS>(line));
}
- if (activeIndices & SC_LINECHARACTERINDEX_UTF16) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
startsUTF16.starts.RemovePartition(static_cast<POS>(line));
}
if (perLine) {
@@ -241,60 +244,60 @@ public:
return starts.PositionFromPartition(static_cast<POS>(line));
}
void InsertCharacters(Sci::Line line, CountWidths delta) noexcept override {
- if (activeIndices & SC_LINECHARACTERINDEX_UTF32) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf32)) {
startsUTF32.starts.InsertText(static_cast<POS>(line), static_cast<POS>(delta.WidthUTF32()));
}
- if (activeIndices & SC_LINECHARACTERINDEX_UTF16) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
startsUTF16.starts.InsertText(static_cast<POS>(line), static_cast<POS>(delta.WidthUTF16()));
}
}
void SetLineCharactersWidth(Sci::Line line, CountWidths width) noexcept override {
- if (activeIndices & SC_LINECHARACTERINDEX_UTF32) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf32)) {
assert(startsUTF32.starts.Partitions() == starts.Partitions());
startsUTF32.SetLineWidth(line, width.WidthUTF32());
}
- if (activeIndices & SC_LINECHARACTERINDEX_UTF16) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
assert(startsUTF16.starts.Partitions() == starts.Partitions());
startsUTF16.SetLineWidth(line, width.WidthUTF16());
}
}
- int LineCharacterIndex() const noexcept override {
+ LineCharacterIndexType LineCharacterIndex() const noexcept override {
return activeIndices;
}
- bool AllocateLineCharacterIndex(int lineCharacterIndex, Sci::Line lines) override {
- const int activeIndicesStart = activeIndices;
- if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF32) != 0) {
+ bool AllocateLineCharacterIndex(LineCharacterIndexType lineCharacterIndex, Sci::Line lines) override {
+ const LineCharacterIndexType activeIndicesStart = activeIndices;
+ if (FlagSet(lineCharacterIndex, LineCharacterIndexType::Utf32)) {
startsUTF32.Allocate(lines);
assert(startsUTF32.starts.Partitions() == starts.Partitions());
}
- if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF16) != 0) {
+ if (FlagSet(lineCharacterIndex, LineCharacterIndexType::Utf16)) {
startsUTF16.Allocate(lines);
assert(startsUTF16.starts.Partitions() == starts.Partitions());
}
SetActiveIndices();
return activeIndicesStart != activeIndices;
}
- bool ReleaseLineCharacterIndex(int lineCharacterIndex) override {
- const int activeIndicesStart = activeIndices;
- if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF32) != 0) {
+ bool ReleaseLineCharacterIndex(LineCharacterIndexType lineCharacterIndex) override {
+ const LineCharacterIndexType activeIndicesStart = activeIndices;
+ if (FlagSet(lineCharacterIndex, LineCharacterIndexType::Utf32)) {
startsUTF32.Release();
}
- if ((lineCharacterIndex & SC_LINECHARACTERINDEX_UTF16) != 0) {
+ if (FlagSet(lineCharacterIndex, LineCharacterIndexType::Utf16)) {
startsUTF16.Release();
}
SetActiveIndices();
return activeIndicesStart != activeIndices;
}
- Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept override {
- if (lineCharacterIndex == SC_LINECHARACTERINDEX_UTF32) {
+ Sci::Position IndexLineStart(Sci::Line line, LineCharacterIndexType lineCharacterIndex) const noexcept override {
+ if (lineCharacterIndex == LineCharacterIndexType::Utf32) {
return startsUTF32.starts.PositionFromPartition(static_cast<POS>(line));
} else {
return startsUTF16.starts.PositionFromPartition(static_cast<POS>(line));
}
}
- Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept override {
- if (lineCharacterIndex == SC_LINECHARACTERINDEX_UTF32) {
+ Sci::Line LineFromPositionIndex(Sci::Position pos, LineCharacterIndexType lineCharacterIndex) const noexcept override {
+ if (lineCharacterIndex == LineCharacterIndexType::Utf32) {
return static_cast<Sci::Line>(startsUTF32.starts.PartitionFromPosition(static_cast<POS>(pos)));
} else {
return static_cast<Sci::Line>(startsUTF16.starts.PartitionFromPosition(static_cast<POS>(pos)));
@@ -570,7 +573,7 @@ CellBuffer::CellBuffer(bool hasStyles_, bool largeDocument_) :
hasStyles(hasStyles_), largeDocument(largeDocument_) {
readOnly = false;
utf8Substance = false;
- utf8LineEnds = 0;
+ utf8LineEnds = LineEndType::Default;
collectingUndo = true;
if (largeDocument)
plv = std::make_unique<LineVector<Sci::Position>>();
@@ -719,9 +722,9 @@ void CellBuffer::SetUTF8Substance(bool utf8Substance_) noexcept {
utf8Substance = utf8Substance_;
}
-void CellBuffer::SetLineEndTypes(int utf8LineEnds_) {
+void CellBuffer::SetLineEndTypes(LineEndType utf8LineEnds_) {
if (utf8LineEnds != utf8LineEnds_) {
- const int indexes = plv->LineCharacterIndex();
+ const LineCharacterIndexType indexes = plv->LineCharacterIndex();
utf8LineEnds = utf8LineEnds_;
ResetLineEnds();
AllocateLineCharacterIndex(indexes);
@@ -735,7 +738,7 @@ bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const noex
const unsigned char ch = s[i];
if ((ch == '\r') || (ch == '\n')) {
return true;
- } else if (utf8LineEnds) {
+ } else if (utf8LineEnds == LineEndType::Unicode) {
if (UTF8IsMultibyteLineEnd(chBeforePrev, chPrev, ch)) {
return true;
}
@@ -750,11 +753,11 @@ void CellBuffer::SetPerLine(PerLine *pl) noexcept {
plv->SetPerLine(pl);
}
-int CellBuffer::LineCharacterIndex() const noexcept {
+LineCharacterIndexType CellBuffer::LineCharacterIndex() const noexcept {
return plv->LineCharacterIndex();
}
-void CellBuffer::AllocateLineCharacterIndex(int lineCharacterIndex) {
+void CellBuffer::AllocateLineCharacterIndex(LineCharacterIndexType lineCharacterIndex) {
if (utf8Substance) {
if (plv->AllocateLineCharacterIndex(lineCharacterIndex, Lines())) {
// Changed so recalculate whole file
@@ -763,7 +766,7 @@ void CellBuffer::AllocateLineCharacterIndex(int lineCharacterIndex) {
}
}
-void CellBuffer::ReleaseLineCharacterIndex(int lineCharacterIndex) {
+void CellBuffer::ReleaseLineCharacterIndex(LineCharacterIndexType lineCharacterIndex) {
plv->ReleaseLineCharacterIndex(lineCharacterIndex);
}
@@ -784,11 +787,11 @@ Sci::Line CellBuffer::LineFromPosition(Sci::Position pos) const noexcept {
return plv->LineFromPosition(pos);
}
-Sci::Position CellBuffer::IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept {
+Sci::Position CellBuffer::IndexLineStart(Sci::Line line, LineCharacterIndexType lineCharacterIndex) const noexcept {
return plv->IndexLineStart(line, lineCharacterIndex);
}
-Sci::Line CellBuffer::LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept {
+Sci::Line CellBuffer::LineFromPositionIndex(Sci::Position pos, LineCharacterIndexType lineCharacterIndex) const noexcept {
return plv->LineFromPositionIndex(pos, lineCharacterIndex);
}
@@ -907,7 +910,7 @@ void CellBuffer::ResetLineEnds() {
InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++;
}
- } else if (utf8LineEnds) {
+ } else if (utf8LineEnds == LineEndType::Unicode) {
if (UTF8IsMultibyteLineEnd(chBeforePrev, chPrev, ch)) {
InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++;
@@ -936,7 +939,7 @@ CountWidths CountCharacterWidthsUTF8(std::string_view sv) noexcept {
}
bool CellBuffer::MaintainingLineCharacterIndex() const noexcept {
- return plv->LineCharacterIndex() != SC_LINECHARACTERINDEX_NONE;
+ return plv->LineCharacterIndex() != LineCharacterIndexType::None;
}
void CellBuffer::RecalculateIndexLineStarts(Sci::Line lineFirst, Sci::Line lineLast) {
@@ -961,7 +964,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
const unsigned char chAfter = substance.ValueAt(position);
bool breakingUTF8LineEnd = false;
- if (utf8LineEnds && UTF8IsTrailByte(chAfter)) {
+ if (utf8LineEnds == LineEndType::Unicode && UTF8IsTrailByte(chAfter)) {
breakingUTF8LineEnd = UTF8LineEndOverlaps(position);
}
@@ -1021,7 +1024,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
uint8_t eolTable[256]{};
eolTable[static_cast<uint8_t>('\n')] = 1;
eolTable[static_cast<uint8_t>('\r')] = 2;
- if (utf8LineEnds) {
+ if (utf8LineEnds == LineEndType::Unicode) {
// see UniConversion.h for LS, PS and NEL
eolTable[0x85] = 4;
eolTable[0xa8] = 3;
@@ -1081,7 +1084,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
if (ch == '\r' || ch == '\n') {
InsertLine(lineInsert, (position + ptr - s), atLineStart);
lineInsert++;
- } else if (utf8LineEnds && !UTF8IsAscii(ch)) {
+ } else if (utf8LineEnds == LineEndType::Unicode && !UTF8IsAscii(ch)) {
if (UTF8IsMultibyteLineEnd(chBeforePrev, chPrev, ch)) {
InsertLine(lineInsert, (position + ptr - s), atLineStart);
lineInsert++;
@@ -1096,7 +1099,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
RemoveLine(lineInsert - 1);
simpleInsertion = false;
}
- } else if (utf8LineEnds && !UTF8IsAscii(chAfter)) {
+ } else if (utf8LineEnds == LineEndType::Unicode && !UTF8IsAscii(chAfter)) {
chBeforePrev = chPrev;
chPrev = ch;
// May have end of UTF-8 line end in buffer and start in insertion
@@ -1177,7 +1180,7 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
lineRemove++;
ignoreNL = true; // First \n is not real deletion
}
- if (utf8LineEnds && UTF8IsTrailByte(chNext)) {
+ if (utf8LineEnds == LineEndType::Unicode && UTF8IsTrailByte(chNext)) {
if (UTF8LineEndOverlaps(position)) {
RemoveLine(lineRemove);
}
@@ -1196,7 +1199,7 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
} else {
RemoveLine(lineRemove);
}
- } else if (utf8LineEnds) {
+ } else if (utf8LineEnds == LineEndType::Unicode) {
if (!UTF8IsAscii(ch)) {
const unsigned char next3[3] = {ch, chNext,
static_cast<unsigned char>(substance.ValueAt(position + i + 2))};
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index 43ee0d884..361c285ad 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -8,7 +8,7 @@
#ifndef CELLBUFFER_H
#define CELLBUFFER_H
-namespace Scintilla {
+namespace Scintilla::Internal {
// Interface to per-line data that wants to see each line insertion and deletion
class PerLine {
@@ -115,7 +115,7 @@ private:
SplitVector<char> style;
bool readOnly;
bool utf8Substance;
- int utf8LineEnds;
+ Scintilla::LineEndType utf8LineEnds;
bool collectingUndo;
UndoHistory uh;
@@ -154,18 +154,18 @@ public:
Sci::Position Length() const noexcept;
void Allocate(Sci::Position newSize);
void SetUTF8Substance(bool utf8Substance_) noexcept;
- int GetLineEndTypes() const noexcept { return utf8LineEnds; }
- void SetLineEndTypes(int utf8LineEnds_);
+ Scintilla::LineEndType GetLineEndTypes() const noexcept { return utf8LineEnds; }
+ void SetLineEndTypes(Scintilla::LineEndType utf8LineEnds_);
bool ContainsLineEnd(const char *s, Sci::Position length) const noexcept;
void SetPerLine(PerLine *pl) noexcept;
- int LineCharacterIndex() const noexcept;
- void AllocateLineCharacterIndex(int lineCharacterIndex);
- void ReleaseLineCharacterIndex(int lineCharacterIndex);
+ Scintilla::LineCharacterIndexType LineCharacterIndex() const noexcept;
+ void AllocateLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
+ void ReleaseLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
Sci::Line Lines() const noexcept;
Sci::Position LineStart(Sci::Line line) const noexcept;
- Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept;
+ Sci::Position IndexLineStart(Sci::Line line, Scintilla::LineCharacterIndexType lineCharacterIndex) const noexcept;
Sci::Line LineFromPosition(Sci::Position pos) const noexcept;
- Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept;
+ Sci::Line LineFromPositionIndex(Sci::Position pos, Scintilla::LineCharacterIndexType lineCharacterIndex) const noexcept;
void InsertLine(Sci::Line line, Sci::Position position, bool lineStart);
void RemoveLine(Sci::Line line);
const char *InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence);
diff --git a/src/CharClassify.cxx b/src/CharClassify.cxx
index 64d720740..caff785b0 100644
--- a/src/CharClassify.cxx
+++ b/src/CharClassify.cxx
@@ -13,7 +13,7 @@
#include "CharacterType.h"
#include "CharClassify.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
CharClassify::CharClassify() : charClass{} {
SetDefaultCharClasses(true);
diff --git a/src/CharClassify.h b/src/CharClassify.h
index 1fcdb9d5d..9fc1be298 100644
--- a/src/CharClassify.h
+++ b/src/CharClassify.h
@@ -8,7 +8,7 @@
#ifndef CHARCLASSIFY_H
#define CHARCLASSIFY_H
-namespace Scintilla {
+namespace Scintilla::Internal {
enum class CharacterClass : unsigned char { space, newLine, word, punctuation };
diff --git a/src/CharacterCategoryMap.cxx b/src/CharacterCategoryMap.cxx
index e9bfecb6a..015b1de39 100644
--- a/src/CharacterCategoryMap.cxx
+++ b/src/CharacterCategoryMap.cxx
@@ -15,7 +15,7 @@
#include "CharacterCategoryMap.h"
-namespace Scintilla {
+namespace Scintilla::Internal {
namespace {
// Use an unnamed namespace to protect the declarations from name conflicts
diff --git a/src/CharacterCategoryMap.h b/src/CharacterCategoryMap.h
index 35706eda7..b3b03eb5a 100644
--- a/src/CharacterCategoryMap.h
+++ b/src/CharacterCategoryMap.h
@@ -10,7 +10,7 @@
#ifndef CHARACTERCATEGORYMAP_H
#define CHARACTERCATEGORYMAP_H
-namespace Scintilla {
+namespace Scintilla::Internal {
enum CharacterCategory {
ccLu, ccLl, ccLt, ccLm, ccLo,
diff --git a/src/CharacterType.cxx b/src/CharacterType.cxx
index 04d6a2abe..2991ac3c4 100644
--- a/src/CharacterType.cxx
+++ b/src/CharacterType.cxx
@@ -10,9 +10,9 @@
#include "CharacterType.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
-namespace Scintilla {
+namespace Scintilla::Internal {
int CompareCaseInsensitive(const char *a, const char *b) noexcept {
while (*a && *b) {
diff --git a/src/CharacterType.h b/src/CharacterType.h
index 1a478cbe4..dcef6aa78 100644
--- a/src/CharacterType.h
+++ b/src/CharacterType.h
@@ -8,7 +8,7 @@
#ifndef CHARACTERTYPE_H
#define CHARACTERTYPE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
// Functions for classifying characters
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx
index 551879c0c..199b3cb78 100644
--- a/src/ContractionState.cxx
+++ b/src/ContractionState.cxx
@@ -26,7 +26,7 @@
#include "SparseVector.h"
#include "ContractionState.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
namespace {
@@ -410,7 +410,7 @@ void ContractionState<LINE>::Check() const noexcept {
}
-namespace Scintilla {
+namespace Scintilla::Internal {
std::unique_ptr<IContractionState> ContractionStateCreate(bool largeDocument) {
if (largeDocument)
diff --git a/src/ContractionState.h b/src/ContractionState.h
index b30d071b4..55c390c55 100644
--- a/src/ContractionState.h
+++ b/src/ContractionState.h
@@ -8,7 +8,7 @@
#ifndef CONTRACTIONSTATE_H
#define CONTRACTIONSTATE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
*/
diff --git a/src/DBCS.cxx b/src/DBCS.cxx
index 148c9818e..0af6fc6eb 100644
--- a/src/DBCS.cxx
+++ b/src/DBCS.cxx
@@ -7,9 +7,9 @@
#include "DBCS.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
-namespace Scintilla {
+namespace Scintilla::Internal {
bool DBCSIsLeadByte(int codePage, char ch) noexcept {
// Byte ranges found in Wikipedia articles with relevant search strings in each case
diff --git a/src/DBCS.h b/src/DBCS.h
index 58659ee3e..c8edad057 100644
--- a/src/DBCS.h
+++ b/src/DBCS.h
@@ -8,7 +8,7 @@
#ifndef DBCS_H
#define DBCS_H
-namespace Scintilla {
+namespace Scintilla::Internal {
constexpr bool IsDBCSCodePage(int codePage) noexcept {
return codePage == 932
diff --git a/src/Debugging.h b/src/Debugging.h
index b7ea20b98..5221ff8e3 100644
--- a/src/Debugging.h
+++ b/src/Debugging.h
@@ -9,7 +9,7 @@
#ifndef DEBUGGING_H
#define DEBUGGING_H
-namespace Scintilla {
+namespace Scintilla::Internal {
#if defined(__clang__)
# if __has_feature(attribute_analyzer_noreturn)
@@ -36,7 +36,7 @@ void Assert(const char *c, const char *file, int line) noexcept CLANG_ANALYZER_N
#ifdef NDEBUG
#define PLATFORM_ASSERT(c) ((void)0)
#else
-#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__))
+#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Internal::Platform::Assert(#c, __FILE__, __LINE__))
#endif
}
diff --git a/src/Decoration.cxx b/src/Decoration.cxx
index 2574854b2..77b2894b2 100644
--- a/src/Decoration.cxx
+++ b/src/Decoration.cxx
@@ -17,16 +17,17 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
-#include "Scintilla.h"
#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
#include "Decoration.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
namespace {
@@ -230,7 +231,7 @@ template <typename POS>
void DecorationList<POS>::DeleteLexerDecorations() {
decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(),
[](const std::unique_ptr<Decoration<POS>> &deco) noexcept {
- return deco->Indicator() < INDICATOR_CONTAINER ;
+ return deco->Indicator() < static_cast<int>(Scintilla::IndicatorNumbers::Container);
}), decorationList.end());
current = nullptr;
SetView();
@@ -261,7 +262,7 @@ int DecorationList<POS>::AllOnFor(Sci::Position position) const noexcept {
int mask = 0;
for (const std::unique_ptr<Decoration<POS>> &deco : decorationList) {
if (deco->rs.ValueAt(static_cast<POS>(position))) {
- if (deco->Indicator() < INDICATOR_IME) {
+ if (deco->Indicator() < static_cast<int>(Scintilla::IndicatorNumbers::Ime)) {
mask |= 1 << deco->Indicator();
}
}
@@ -298,7 +299,7 @@ Sci::Position DecorationList<POS>::End(int indicator, Sci::Position position) no
}
-namespace Scintilla {
+namespace Scintilla::Internal {
std::unique_ptr<IDecoration> DecorationCreate(bool largeDocument, int indicator) {
if (largeDocument)
diff --git a/src/Decoration.h b/src/Decoration.h
index bab8e2500..c8faafec9 100644
--- a/src/Decoration.h
+++ b/src/Decoration.h
@@ -7,7 +7,7 @@
#ifndef DECORATION_H
#define DECORATION_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class IDecoration {
public:
diff --git a/src/Document.cxx b/src/Document.cxx
index c8f474eaa..70a711028 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -26,11 +26,11 @@
#include <regex>
#endif
-#include "Debugging.h"
-
+#include "ScintillaTypes.h"
#include "ILoader.h"
#include "ILexer.h"
-#include "Scintilla.h"
+
+#include "Debugging.h"
#include "CharacterType.h"
#include "CharacterCategoryMap.h"
@@ -49,6 +49,7 @@
#include "ElapsedPeriod.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
void LexInterface::Colourise(Sci::Position start, Sci::Position end) {
if (pdoc && instance && !performingStyle) {
@@ -78,11 +79,11 @@ void LexInterface::Colourise(Sci::Position start, Sci::Position end) {
}
}
-int LexInterface::LineEndTypesSupported() {
+LineEndType LexInterface::LineEndTypesSupported() {
if (instance) {
- return instance->LineEndTypesSupported();
+ return static_cast<LineEndType>(instance->LineEndTypesSupported());
}
- return 0;
+ return LineEndType::Default;
}
ActionDuration::ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept :
@@ -111,17 +112,17 @@ size_t ActionDuration::ActionsInAllowedTime(double secondsAllowed) const noexcep
return std::lround(secondsAllowed / Duration());
}
-Document::Document(int options) :
- cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0),
+Document::Document(DocumentOption options) :
+ cb((FlagSet(options, DocumentOption::StylesNone)) == 0, (FlagSet(options, DocumentOption::TextLarge)) != 0),
durationStyleOneByte(0.000001, 0.0000001, 0.00001) {
refCount = 0;
#ifdef _WIN32
- eolMode = SC_EOL_CRLF;
+ eolMode = EndOfLine::CrLf;
#else
- eolMode = SC_EOL_LF;
+ eolMode = EndOfLine::Lf;
#endif
- dbcsCodePage = SC_CP_UTF8;
- lineEndBitSet = SC_LINE_END_TYPE_DEFAULT;
+ dbcsCodePage = CpUtf8;
+ lineEndBitSet = LineEndType::Default;
endStyled = 0;
styleClock = 0;
enteredModification = 0;
@@ -147,7 +148,7 @@ Document::Document(int options) :
decorations = DecorationListCreate(IsLarge());
cb.SetPerLine(this);
- cb.SetUTF8Substance(SC_CP_UTF8 == dbcsCodePage);
+ cb.SetUTF8Substance(CpUtf8 == dbcsCodePage);
}
Document::~Document() {
@@ -222,11 +223,11 @@ LineAnnotation *Document::EOLAnnotations() const noexcept {
return dynamic_cast<LineAnnotation *>(perLineData[ldEOLAnnotation].get());
}
-int Document::LineEndTypesSupported() const {
- if ((SC_CP_UTF8 == dbcsCodePage) && pli)
+LineEndType Document::LineEndTypesSupported() const {
+ if ((CpUtf8 == dbcsCodePage) && pli)
return pli->LineEndTypesSupported();
else
- return 0;
+ return LineEndType::Default;
}
bool Document::SetDBCSCodePage(int dbcsCodePage_) {
@@ -234,7 +235,7 @@ bool Document::SetDBCSCodePage(int dbcsCodePage_) {
dbcsCodePage = dbcsCodePage_;
SetCaseFolder(nullptr);
cb.SetLineEndTypes(lineEndBitSet & LineEndTypesSupported());
- cb.SetUTF8Substance(SC_CP_UTF8 == dbcsCodePage);
+ cb.SetUTF8Substance(CpUtf8 == dbcsCodePage);
ModifiedAt(0); // Need to restyle whole document
return true;
} else {
@@ -242,10 +243,10 @@ bool Document::SetDBCSCodePage(int dbcsCodePage_) {
}
}
-bool Document::SetLineEndTypesAllowed(int lineEndBitSet_) {
+bool Document::SetLineEndTypesAllowed(LineEndType lineEndBitSet_) {
if (lineEndBitSet != lineEndBitSet_) {
lineEndBitSet = lineEndBitSet_;
- const int lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported();
+ const LineEndType lineEndBitSetActive = lineEndBitSet & LineEndTypesSupported();
if (lineEndBitSetActive != cb.GetLineEndTypes()) {
ModifiedAt(0);
cb.SetLineEndTypes(lineEndBitSetActive);
@@ -279,36 +280,36 @@ void Document::TentativeUndo() {
const Action &action = cb.GetUndoStep();
if (action.at == ActionType::remove) {
NotifyModified(DocModification(
- SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action));
+ ModificationFlags::BeforeInsert | ModificationFlags::Undo, action));
} else if (action.at == ActionType::container) {
- DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_UNDO);
+ DocModification dm(ModificationFlags::Container | ModificationFlags::Undo);
dm.token = action.position;
NotifyModified(dm);
} else {
NotifyModified(DocModification(
- SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action));
+ ModificationFlags::BeforeDelete | ModificationFlags::Undo, action));
}
cb.PerformUndoStep();
if (action.at != ActionType::container) {
ModifiedAt(action.position);
}
- int modFlags = SC_PERFORMED_UNDO;
+ ModificationFlags modFlags = ModificationFlags::Undo;
// With undo, an insertion action becomes a deletion notification
if (action.at == ActionType::remove) {
- modFlags |= SC_MOD_INSERTTEXT;
+ modFlags |= ModificationFlags::InsertText;
} else if (action.at == ActionType::insert) {
- modFlags |= SC_MOD_DELETETEXT;
+ modFlags |= ModificationFlags::DeleteText;
}
if (steps > 1)
- modFlags |= SC_MULTISTEPUNDOREDO;
+ modFlags |= ModificationFlags::MultiStepUndoRedo;
const Sci::Line linesAdded = LinesTotal() - prevLinesTotal;
if (linesAdded != 0)
multiLine = true;
if (step == steps - 1) {
- modFlags |= SC_LASTSTEPINUNDOREDO;
+ modFlags |= ModificationFlags::LastStepInUndoRedo;
if (multiLine)
- modFlags |= SC_MULTILINEUNDOREDO;
+ modFlags |= ModificationFlags::MultilineUndoRedo;
}
NotifyModified(DocModification(modFlags, action.position, action.lenData,
linesAdded, action.data.get()));
@@ -335,7 +336,7 @@ Sci::Line Document::MarkerNext(Sci::Line lineStart, int mask) const noexcept {
int Document::AddMark(Sci::Line line, int markerNum) {
if (line >= 0 && line <= LinesTotal()) {
const int prev = Markers()->AddMark(line, markerNum, LinesTotal());
- const DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, nullptr, line);
+ const DocModification mh(ModificationFlags::ChangeMarker, LineStart(line), 0, 0, nullptr, line);
NotifyModified(mh);
return prev;
} else {
@@ -352,19 +353,19 @@ void Document::AddMarkSet(Sci::Line line, int valueSet) {
if (m & 1)
Markers()->AddMark(line, i, LinesTotal());
}
- const DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, nullptr, line);
+ const DocModification mh(ModificationFlags::ChangeMarker, LineStart(line), 0, 0, nullptr, line);
NotifyModified(mh);
}
void Document::DeleteMark(Sci::Line line, int markerNum) {
Markers()->DeleteMark(line, markerNum, false);
- const DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, nullptr, line);
+ const DocModification mh(ModificationFlags::ChangeMarker, LineStart(line), 0, 0, nullptr, line);
NotifyModified(mh);
}
void Document::DeleteMarkFromHandle(int markerHandle) {
Markers()->DeleteMarkFromHandle(markerHandle);
- DocModification mh(SC_MOD_CHANGEMARKER);
+ DocModification mh(ModificationFlags::ChangeMarker);
mh.line = -1;
NotifyModified(mh);
}
@@ -376,7 +377,7 @@ void Document::DeleteAllMarks(int markerNum) {
someChanges = true;
}
if (someChanges) {
- DocModification mh(SC_MOD_CHANGEMARKER);
+ DocModification mh(ModificationFlags::ChangeMarker);
mh.line = -1;
NotifyModified(mh);
}
@@ -407,7 +408,7 @@ Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const {
return LineStart(line + 1);
} else {
Sci::Position position = LineStart(line + 1);
- if (SC_LINE_END_TYPE_UNICODE == cb.GetLineEndTypes()) {
+ if (LineEndType::Unicode == cb.GetLineEndTypes()) {
const unsigned char bytes[] = {
cb.UCharAt(position-3),
cb.UCharAt(position-2),
@@ -432,7 +433,7 @@ Sci_Position SCI_METHOD Document::LineEnd(Sci_Position line) const {
void SCI_METHOD Document::SetErrorStatus(int status) {
// Tell the watchers an error has occurred.
for (const WatcherWithUserData &watcher : watchers) {
- watcher.watcher->NotifyErrorOccurred(this, watcher.userData, status);
+ watcher.watcher->NotifyErrorOccurred(this, watcher.userData, static_cast<Status>(status));
}
}
@@ -470,11 +471,11 @@ Sci::Position Document::VCHomePosition(Sci::Position position) const {
return startText;
}
-Sci::Position Document::IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept {
+Sci::Position Document::IndexLineStart(Sci::Line line, LineCharacterIndexType lineCharacterIndex) const noexcept {
return cb.IndexLineStart(line, lineCharacterIndex);
}
-Sci::Line Document::LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept {
+Sci::Line Document::LineFromPositionIndex(Sci::Position pos, LineCharacterIndexType lineCharacterIndex) const noexcept {
return cb.LineFromPositionIndex(pos, lineCharacterIndex);
}
@@ -495,10 +496,10 @@ Sci::Line Document::LineFromPositionAfter(Sci::Line line, Sci::Position length)
int SCI_METHOD Document::SetLevel(Sci_Position line, int level) {
const int prev = Levels()->SetLevel(line, level, LinesTotal());
if (prev != level) {
- DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
+ DocModification mh(ModificationFlags::ChangeFold | ModificationFlags::ChangeMarker,
LineStart(line), 0, 0, nullptr, line);
- mh.foldLevelNow = level;
- mh.foldLevelPrev = prev;
+ mh.foldLevelNow = static_cast<FoldLevel>(level);
+ mh.foldLevelPrev = static_cast<FoldLevel>(prev);
NotifyModified(mh);
}
return prev;
@@ -508,35 +509,39 @@ int SCI_METHOD Document::GetLevel(Sci_Position line) const {
return Levels()->GetLevel(line);
}
+FoldLevel Document::GetFoldLevel(Sci_Position line) const {
+ return static_cast<FoldLevel>(Levels()->GetLevel(line));
+}
+
void Document::ClearLevels() {
Levels()->ClearLevels();
}
-static bool IsSubordinate(int levelStart, int levelTry) noexcept {
+static bool IsSubordinate(FoldLevel levelStart, FoldLevel levelTry) noexcept {
if (LevelIsWhitespace(levelTry))
return true;
else
return LevelNumber(levelStart) < LevelNumber(levelTry);
}
-Sci::Line Document::GetLastChild(Sci::Line lineParent, int level, Sci::Line lastLine) {
- if (level == -1)
- level = LevelNumber(GetLevel(lineParent));
+Sci::Line Document::GetLastChild(Sci::Line lineParent, std::optional<FoldLevel> level, Sci::Line lastLine) {
+ if (!level)
+ level = LevelNumberPart(GetFoldLevel(lineParent));
const Sci::Line maxLine = LinesTotal();
const Sci::Line lookLastLine = (lastLine != -1) ? std::min(LinesTotal() - 1, lastLine) : -1;
Sci::Line lineMaxSubord = lineParent;
while (lineMaxSubord < maxLine - 1) {
EnsureStyledTo(LineStart(lineMaxSubord + 2));
- if (!IsSubordinate(level, GetLevel(lineMaxSubord + 1)))
+ if (!IsSubordinate(*level, GetFoldLevel(lineMaxSubord + 1)))
break;
- if ((lookLastLine != -1) && (lineMaxSubord >= lookLastLine) && !LevelIsWhitespace(GetLevel(lineMaxSubord)))
+ if ((lookLastLine != -1) && (lineMaxSubord >= lookLastLine) && !LevelIsWhitespace(GetFoldLevel(lineMaxSubord)))
break;
lineMaxSubord++;
}
if (lineMaxSubord > lineParent) {
- if (level > LevelNumber(GetLevel(lineMaxSubord + 1))) {
+ if (level > LevelNumberPart(GetFoldLevel(lineMaxSubord + 1))) {
// Have chewed up some whitespace that belongs to a parent so seek back
- if (LevelIsWhitespace(GetLevel(lineMaxSubord))) {
+ if (LevelIsWhitespace(GetFoldLevel(lineMaxSubord))) {
lineMaxSubord--;
}
}
@@ -545,16 +550,16 @@ Sci::Line Document::GetLastChild(Sci::Line lineParent, int level, Sci::Line last
}
Sci::Line Document::GetFoldParent(Sci::Line line) const {
- const int level = LevelNumber(GetLevel(line));
+ const FoldLevel level = LevelNumberPart(GetFoldLevel(line));
Sci::Line lineLook = line - 1;
while ((lineLook > 0) && (
- (!LevelIsHeader(GetLevel(lineLook))) ||
- (LevelNumber(GetLevel(lineLook)) >= level))
+ (!LevelIsHeader(GetFoldLevel(lineLook))) ||
+ (LevelNumberPart(GetFoldLevel(lineLook)) >= level))
) {
lineLook--;
}
- if (LevelIsHeader(GetLevel(lineLook)) &&
- (LevelNumber(GetLevel(lineLook)) < level)) {
+ if (LevelIsHeader(GetFoldLevel(lineLook)) &&
+ (LevelNumberPart(GetFoldLevel(lineLook)) < level)) {
return lineLook;
} else {
return -1;
@@ -562,16 +567,16 @@ Sci::Line Document::GetFoldParent(Sci::Line line) const {
}
void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine) {
- const int level = GetLevel(line);
+ const FoldLevel level = GetFoldLevel(line);
const Sci::Line lookLastLine = std::max(line, lastLine) + 1;
Sci::Line lookLine = line;
- int lookLineLevel = level;
- int lookLineLevelNum = LevelNumber(lookLineLevel);
+ FoldLevel lookLineLevel = level;
+ FoldLevel lookLineLevelNum = LevelNumberPart(lookLineLevel);
while ((lookLine > 0) && (LevelIsWhitespace(lookLineLevel) ||
- (LevelIsHeader(lookLineLevel) && (lookLineLevelNum >= LevelNumber(GetLevel(lookLine + 1)))))) {
- lookLineLevel = GetLevel(--lookLine);
- lookLineLevelNum = LevelNumber(lookLineLevel);
+ (LevelIsHeader(lookLineLevel) && (lookLineLevelNum >= LevelNumberPart(GetFoldLevel(lookLine + 1)))))) {
+ lookLineLevel = GetFoldLevel(--lookLine);
+ lookLineLevelNum = LevelNumberPart(lookLineLevel);
}
Sci::Line beginFoldBlock = LevelIsHeader(lookLineLevel) ? lookLine : GetFoldParent(lookLine);
@@ -580,31 +585,31 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sc
return;
}
- Sci::Line endFoldBlock = GetLastChild(beginFoldBlock, -1, lookLastLine);
+ Sci::Line endFoldBlock = GetLastChild(beginFoldBlock, {}, lookLastLine);
Sci::Line firstChangeableLineBefore = -1;
if (endFoldBlock < line) {
lookLine = beginFoldBlock - 1;
- lookLineLevel = GetLevel(lookLine);
- lookLineLevelNum = LevelNumber(lookLineLevel);
- while ((lookLine >= 0) && (lookLineLevelNum >= SC_FOLDLEVELBASE)) {
+ lookLineLevel = GetFoldLevel(lookLine);
+ lookLineLevelNum = LevelNumberPart(lookLineLevel);
+ while ((lookLine >= 0) && (lookLineLevelNum >= FoldLevel::Base)) {
if (LevelIsHeader(lookLineLevel)) {
- if (GetLastChild(lookLine, -1, lookLastLine) == line) {
+ if (GetLastChild(lookLine, {}, lookLastLine) == line) {
beginFoldBlock = lookLine;
endFoldBlock = line;
firstChangeableLineBefore = line - 1;
}
}
- if ((lookLine > 0) && (lookLineLevelNum == SC_FOLDLEVELBASE) && (LevelNumber(GetLevel(lookLine - 1)) > lookLineLevelNum))
+ if ((lookLine > 0) && (lookLineLevelNum == FoldLevel::Base) && (LevelNumberPart(GetFoldLevel(lookLine - 1)) > lookLineLevelNum))
break;
- lookLineLevel = GetLevel(--lookLine);
- lookLineLevelNum = LevelNumber(lookLineLevel);
+ lookLineLevel = GetFoldLevel(--lookLine);
+ lookLineLevelNum = LevelNumberPart(lookLineLevel);
}
}
if (firstChangeableLineBefore == -1) {
- for (lookLine = line - 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = LevelNumber(lookLineLevel);
+ for (lookLine = line - 1, lookLineLevel = GetFoldLevel(lookLine), lookLineLevelNum = LevelNumberPart(lookLineLevel);
lookLine >= beginFoldBlock;
- lookLineLevel = GetLevel(--lookLine), lookLineLevelNum = LevelNumber(lookLineLevel)) {
- if (LevelIsWhitespace(lookLineLevel) || (lookLineLevelNum > LevelNumber(level))) {
+ lookLineLevel = GetFoldLevel(--lookLine), lookLineLevelNum = LevelNumberPart(lookLineLevel)) {
+ if (LevelIsWhitespace(lookLineLevel) || (lookLineLevelNum > LevelNumberPart(level))) {
firstChangeableLineBefore = lookLine;
break;
}
@@ -614,10 +619,10 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sc
firstChangeableLineBefore = beginFoldBlock - 1;
Sci::Line firstChangeableLineAfter = -1;
- for (lookLine = line + 1, lookLineLevel = GetLevel(lookLine), lookLineLevelNum = LevelNumber(lookLineLevel);
+ for (lookLine = line + 1, lookLineLevel = GetFoldLevel(lookLine), lookLineLevelNum = LevelNumberPart(lookLineLevel);
lookLine <= endFoldBlock;
- lookLineLevel = GetLevel(++lookLine), lookLineLevelNum = LevelNumber(lookLineLevel)) {
- if (LevelIsHeader(lookLineLevel) && (lookLineLevelNum < LevelNumber(GetLevel(lookLine + 1)))) {
+ lookLineLevel = GetFoldLevel(++lookLine), lookLineLevelNum = LevelNumberPart(lookLineLevel)) {
+ if (LevelIsHeader(lookLineLevel) && (lookLineLevelNum < LevelNumberPart(GetFoldLevel(lookLine + 1)))) {
firstChangeableLineAfter = lookLine;
break;
}
@@ -656,7 +661,7 @@ int Document::LenChar(Sci::Position pos) const noexcept {
// Common case: ASCII character
return 1;
}
- if (SC_CP_UTF8 == dbcsCodePage) {
+ if (CpUtf8 == dbcsCodePage) {
const int widthCharBytes = UTF8BytesOfLead[leadByte];
unsigned char charBytes[UTF8MaxBytes] = { leadByte, 0, 0, 0 };
for (int b = 1; b < widthCharBytes; b++) {
@@ -727,7 +732,7 @@ Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position
}
if (dbcsCodePage) {
- if (SC_CP_UTF8 == dbcsCodePage) {
+ if (CpUtf8 == dbcsCodePage) {
const unsigned char ch = cb.UCharAt(pos);
// If ch is not a trail byte then pos is valid intercharacter position
if (UTF8IsTrailByte(ch)) {
@@ -786,7 +791,7 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const noexc
return cb.Length();
if (dbcsCodePage) {
- if (SC_CP_UTF8 == dbcsCodePage) {
+ if (CpUtf8 == dbcsCodePage) {
if (increment == 1) {
// Simple forward movement case so can avoid some checks
const unsigned char leadByte = cb.UCharAt(pos);
@@ -875,7 +880,7 @@ Document::CharacterExtracted Document::CharacterAfter(Sci::Position position) co
// Common case: ASCII character
return CharacterExtracted(leadByte, 1);
}
- if (SC_CP_UTF8 == dbcsCodePage) {
+ if (CpUtf8 == dbcsCodePage) {
const int widthCharBytes = UTF8BytesOfLead[leadByte];
unsigned char charBytes[UTF8MaxBytes] = { leadByte, 0, 0, 0 };
for (int b = 1; b<widthCharBytes; b++)
@@ -904,7 +909,7 @@ Document::CharacterExtracted Document::CharacterBefore(Sci::Position position) c
if (0 == dbcsCodePage) {
return CharacterExtracted(previousByte, 1);
}
- if (SC_CP_UTF8 == dbcsCodePage) {
+ if (CpUtf8 == dbcsCodePage) {
if (UTF8IsAscii(previousByte)) {
return CharacterExtracted(previousByte, 1);
}
@@ -983,7 +988,7 @@ int SCI_METHOD Document::GetCharacterAndWidth(Sci_Position position, Sci_Positio
int bytesInCharacter = 1;
const unsigned char leadByte = cb.UCharAt(position);
if (dbcsCodePage) {
- if (SC_CP_UTF8 == dbcsCodePage) {
+ if (CpUtf8 == dbcsCodePage) {
if (UTF8IsAscii(leadByte)) {
// Single byte character or invalid
character = leadByte;
@@ -1176,7 +1181,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const
}
lastEncodingAllowedBreak = j;
- if (dbcsCodePage == SC_CP_UTF8) {
+ if (dbcsCodePage == CpUtf8) {
j += UTF8BytesOfLead[ch];
} else if (dbcsCodePage) {
j += IsDBCSLeadByteNoExcept(ch) ? 2 : 1;
@@ -1193,7 +1198,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const
}
EncodingFamily Document::CodePageFamily() const noexcept {
- if (SC_CP_UTF8 == dbcsCodePage)
+ if (CpUtf8 == dbcsCodePage)
return EncodingFamily::unicode;
else if (dbcsCodePage)
return EncodingFamily::dbcs;
@@ -1232,7 +1237,7 @@ bool Document::DeleteChars(Sci::Position pos, Sci::Position len) {
if (!cb.IsReadOnly()) {
NotifyModified(
DocModification(
- SC_MOD_BEFOREDELETE | SC_PERFORMED_USER,
+ ModificationFlags::BeforeDelete | ModificationFlags::User,
pos, len,
0, 0));
const Sci::Line prevLinesTotal = LinesTotal();
@@ -1247,7 +1252,8 @@ bool Document::DeleteChars(Sci::Position pos, Sci::Position len) {
ModifiedAt(pos-1);
NotifyModified(
DocModification(
- SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
+ ModificationFlags::DeleteText | ModificationFlags::User |
+ (startSequence?ModificationFlags::StartAction:ModificationFlags::None),
pos, len,
LinesTotal() - prevLinesTotal, text));
}
@@ -1275,7 +1281,7 @@ Sci::Position Document::InsertString(Sci::Position position, const char *s, Sci:
insertion.clear();
NotifyModified(
DocModification(
- SC_MOD_INSERTCHECK,
+ ModificationFlags::InsertCheck,
position, insertLength,
0, s));
if (insertionSet) {
@@ -1284,7 +1290,7 @@ Sci::Position Document::InsertString(Sci::Position position, const char *s, Sci:
}
NotifyModified(
DocModification(
- SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
+ ModificationFlags::BeforeInsert | ModificationFlags::User,
position, insertLength,
0, s));
const Sci::Line prevLinesTotal = LinesTotal();
@@ -1296,7 +1302,8 @@ Sci::Position Document::InsertString(Sci::Position position, const char *s, Sci:
ModifiedAt(position);
NotifyModified(
DocModification(
- SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
+ ModificationFlags::InsertText | ModificationFlags::User |
+ (startSequence?ModificationFlags::StartAction:ModificationFlags::None),
position, insertLength,
LinesTotal() - prevLinesTotal, text));
if (insertionSet) { // Free memory as could be large
@@ -1316,11 +1323,11 @@ int SCI_METHOD Document::AddData(const char *data, Sci_Position length) {
const Sci::Position position = Length();
InsertString(position, data, length);
} catch (std::bad_alloc &) {
- return SC_STATUS_BADALLOC;
+ return static_cast<int>(Status::BadAlloc);
} catch (...) {
- return SC_STATUS_FAILURE;
+ return static_cast<int>(Status::Failure);
}
- return 0;
+ return static_cast<int>(Status::Ok);
}
void * SCI_METHOD Document::ConvertToDocument() {
@@ -1346,9 +1353,9 @@ Sci::Position Document::Undo() {
const Action &action = cb.GetUndoStep();
if (action.at == ActionType::remove) {
NotifyModified(DocModification(
- SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action));
+ ModificationFlags::BeforeInsert | ModificationFlags::Undo, action));
} else if (action.at == ActionType::container) {
- DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_UNDO);
+ DocModification dm(ModificationFlags::Container | ModificationFlags::Undo);
dm.token = action.position;
NotifyModified(dm);
if (!action.mayCoalesce) {
@@ -1359,7 +1366,7 @@ Sci::Position Document::Undo() {
}
} else {
NotifyModified(DocModification(
- SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action));
+ ModificationFlags::BeforeDelete | ModificationFlags::Undo, action));
}
cb.PerformUndoStep();
if (action.at != ActionType::container) {
@@ -1367,11 +1374,11 @@ Sci::Position Document::Undo() {
newPos = action.position;
}
- int modFlags = SC_PERFORMED_UNDO;
+ ModificationFlags modFlags = ModificationFlags::Undo;
// With undo, an insertion action becomes a deletion notification
if (action.at == ActionType::remove) {
newPos += action.lenData;
- modFlags |= SC_MOD_INSERTTEXT;
+ modFlags |= ModificationFlags::InsertText;
if ((coalescedRemoveLen > 0) &&
(action.position == prevRemoveActionPos || action.position == (prevRemoveActionPos + prevRemoveActionLen))) {
coalescedRemoveLen += action.lenData;
@@ -1383,21 +1390,21 @@ Sci::Position Document::Undo() {
prevRemoveActionPos = action.position;
prevRemoveActionLen = action.lenData;
} else if (action.at == ActionType::insert) {
- modFlags |= SC_MOD_DELETETEXT;
+ modFlags |= ModificationFlags::DeleteText;
coalescedRemovePos = -1;
coalescedRemoveLen = 0;
prevRemoveActionPos = -1;
prevRemoveActionLen = 0;
}
if (steps > 1)
- modFlags |= SC_MULTISTEPUNDOREDO;
+ modFlags |= ModificationFlags::MultiStepUndoRedo;
const Sci::Line linesAdded = LinesTotal() - prevLinesTotal;
if (linesAdded != 0)
multiLine = true;
if (step == steps - 1) {
- modFlags |= SC_LASTSTEPINUNDOREDO;
+ modFlags |= ModificationFlags::LastStepInUndoRedo;
if (multiLine)
- modFlags |= SC_MULTILINEUNDOREDO;
+ modFlags |= ModificationFlags::MultilineUndoRedo;
}
NotifyModified(DocModification(modFlags, action.position, action.lenData,
linesAdded, action.data.get()));
@@ -1426,14 +1433,14 @@ Sci::Position Document::Redo() {
const Action &action = cb.GetRedoStep();
if (action.at == ActionType::insert) {
NotifyModified(DocModification(
- SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action));
+ ModificationFlags::BeforeInsert | ModificationFlags::Redo, action));
} else if (action.at == ActionType::container) {
- DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_REDO);
+ DocModification dm(ModificationFlags::Container | ModificationFlags::Redo);
dm.token = action.position;
NotifyModified(dm);
} else {
NotifyModified(DocModification(
- SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action));
+ ModificationFlags::BeforeDelete | ModificationFlags::Redo, action));
}
cb.PerformRedoStep();
if (action.at != ActionType::container) {
@@ -1441,22 +1448,22 @@ Sci::Position Document::Redo() {
newPos = action.position;
}
- int modFlags = SC_PERFORMED_REDO;
+ ModificationFlags modFlags = ModificationFlags::Redo;
if (action.at == ActionType::insert) {
newPos += action.lenData;
- modFlags |= SC_MOD_INSERTTEXT;
+ modFlags |= ModificationFlags::InsertText;
} else if (action.at == ActionType::remove) {
- modFlags |= SC_MOD_DELETETEXT;
+ modFlags |= ModificationFlags::DeleteText;
}
if (steps > 1)
- modFlags |= SC_MULTISTEPUNDOREDO;
+ modFlags |= ModificationFlags::MultiStepUndoRedo;
const Sci::Line linesAdded = LinesTotal() - prevLinesTotal;
if (linesAdded != 0)
multiLine = true;
if (step == steps - 1) {
- modFlags |= SC_LASTSTEPINUNDOREDO;
+ modFlags |= ModificationFlags::LastStepInUndoRedo;
if (multiLine)
- modFlags |= SC_MULTILINEUNDOREDO;
+ modFlags |= ModificationFlags::MultilineUndoRedo;
}
NotifyModified(
DocModification(modFlags, action.position, action.lenData,
@@ -1645,15 +1652,15 @@ void Document::Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop) {
// Convert line endings for a piece of text to a particular mode.
// Stop at len or when a NUL is found.
-std::string Document::TransformLineEnds(const char *s, size_t len, int eolModeWanted) {
+std::string Document::TransformLineEnds(const char *s, size_t len, EndOfLine eolModeWanted) {
std::string dest;
for (size_t i = 0; (i < len) && (s[i]); i++) {
if (s[i] == '\n' || s[i] == '\r') {
- if (eolModeWanted == SC_EOL_CR) {
+ if (eolModeWanted == EndOfLine::Cr) {
dest.push_back('\r');
- } else if (eolModeWanted == SC_EOL_LF) {
+ } else if (eolModeWanted == EndOfLine::Lf) {
dest.push_back('\n');
- } else { // eolModeWanted == SC_EOL_CRLF
+ } else { // eolModeWanted == EndOfLine::CrLf
dest.push_back('\r');
dest.push_back('\n');
}
@@ -1667,25 +1674,25 @@ std::string Document::TransformLineEnds(const char *s, size_t len, int eolModeWa
return dest;
}
-void Document::ConvertLineEnds(int eolModeSet) {
+void Document::ConvertLineEnds(EndOfLine eolModeSet) {
UndoGroup ug(this);
for (Sci::Position pos = 0; pos < Length(); pos++) {
if (cb.CharAt(pos) == '\r') {
if (cb.CharAt(pos + 1) == '\n') {
// CRLF
- if (eolModeSet == SC_EOL_CR) {
+ if (eolModeSet == EndOfLine::Cr) {
DeleteChars(pos + 1, 1); // Delete the LF
- } else if (eolModeSet == SC_EOL_LF) {
+ } else if (eolModeSet == EndOfLine::Lf) {
DeleteChars(pos, 1); // Delete the CR
} else {
pos++;
}
} else {
// CR
- if (eolModeSet == SC_EOL_CRLF) {
+ if (eolModeSet == EndOfLine::CrLf) {
pos += InsertString(pos + 1, "\n", 1); // Insert LF
- } else if (eolModeSet == SC_EOL_LF) {
+ } else if (eolModeSet == EndOfLine::Lf) {
pos += InsertString(pos, "\n", 1); // Insert LF
DeleteChars(pos, 1); // Delete CR
pos--;
@@ -1693,9 +1700,9 @@ void Document::ConvertLineEnds(int eolModeSet) {
}
} else if (cb.CharAt(pos) == '\n') {
// LF
- if (eolModeSet == SC_EOL_CRLF) {
+ if (eolModeSet == EndOfLine::CrLf) {
pos += InsertString(pos, "\r", 1); // Insert CR
- } else if (eolModeSet == SC_EOL_CR) {
+ } else if (eolModeSet == EndOfLine::Cr) {
pos += InsertString(pos, "\r", 1); // Insert CR
DeleteChars(pos, 1); // Delete LF
pos--;
@@ -1705,9 +1712,9 @@ void Document::ConvertLineEnds(int eolModeSet) {
}
-int Document::Options() const noexcept {
- return (IsLarge() ? SC_DOCUMENTOPTION_TEXT_LARGE : 0) |
- (cb.HasStyles() ? 0 : SC_DOCUMENTOPTION_STYLES_NONE);
+DocumentOption Document::Options() const noexcept {
+ return (IsLarge() ? DocumentOption::TextLarge : DocumentOption::Default) |
+ (cb.HasStyles() ? DocumentOption::Default : DocumentOption::StylesNone);
}
bool Document::IsWhiteLine(Sci::Line line) const {
@@ -1751,7 +1758,7 @@ Sci::Position Document::ParaDown(Sci::Position pos) const {
CharacterClass Document::WordCharacterClass(unsigned int ch) const {
if (dbcsCodePage && (!UTF8IsAscii(ch))) {
- if (SC_CP_UTF8 == dbcsCodePage) {
+ if (CpUtf8 == dbcsCodePage) {
// Use hard coded Unicode class
const CharacterCategory cc = charMap.CategoryFor(ch);
switch (cc) {
@@ -2018,13 +2025,13 @@ Document::CharacterExtracted Document::ExtractCharacter(Sci::Position position)
* Has not been tested with backwards DBCS searches yet.
*/
Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, const char *search,
- int flags, Sci::Position *length) {
+ FindOption flags, Sci::Position *length) {
if (*length <= 0)
return minPos;
- const bool caseSensitive = (flags & SCFIND_MATCHCASE) != 0;
- const bool word = (flags & SCFIND_WHOLEWORD) != 0;
- const bool wordStart = (flags & SCFIND_WORDSTART) != 0;
- const bool regExp = (flags & SCFIND_REGEXP) != 0;
+ const bool caseSensitive = FlagSet(flags, FindOption::MatchCase);
+ const bool word = FlagSet(flags, FindOption::WholeWord);
+ const bool wordStart = FlagSet(flags, FindOption::WordStart);
+ const bool regExp = FlagSet(flags, FindOption::RegExp);
if (regExp) {
if (!regex)
regex = std::unique_ptr<RegexSearchBase>(CreateRegexSearch(&charClass));
@@ -2064,7 +2071,7 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con
if (!NextCharacter(pos, increment))
break;
}
- } else if (SC_CP_UTF8 == dbcsCodePage) {
+ } else if (CpUtf8 == dbcsCodePage) {
constexpr size_t maxFoldingExpansion = 4;
std::vector<char> searchThing((lengthFind+1) * UTF8MaxBytes * maxFoldingExpansion + 1);
const size_t lenSearch =
@@ -2184,15 +2191,15 @@ const char *Document::SubstituteByPosition(const char *text, Sci::Position *leng
return nullptr;
}
-int Document::LineCharacterIndex() const noexcept {
+LineCharacterIndexType Document::LineCharacterIndex() const noexcept {
return cb.LineCharacterIndex();
}
-void Document::AllocateLineCharacterIndex(int lineCharacterIndex) {
+void Document::AllocateLineCharacterIndex(LineCharacterIndexType lineCharacterIndex) {
return cb.AllocateLineCharacterIndex(lineCharacterIndex);
}
-void Document::ReleaseLineCharacterIndex(int lineCharacterIndex) {
+void Document::ReleaseLineCharacterIndex(LineCharacterIndexType lineCharacterIndex) {
return cb.ReleaseLineCharacterIndex(lineCharacterIndex);
}
@@ -2231,7 +2238,7 @@ bool SCI_METHOD Document::SetStyleFor(Sci_Position length, char style) {
enteredStyling++;
const Sci::Position prevEndStyled = endStyled;
if (cb.SetStyleFor(endStyled, length, style)) {
- const DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
+ const DocModification mh(ModificationFlags::ChangeStyle | ModificationFlags::User,
prevEndStyled, length);
NotifyModified(mh);
}
@@ -2260,7 +2267,7 @@ bool SCI_METHOD Document::SetStyles(Sci_Position length, const char *styles) {
}
}
if (didChange) {
- const DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER,
+ const DocModification mh(ModificationFlags::ChangeStyle | ModificationFlags::User,
startMod, endMod - startMod + 1);
NotifyModified(mh);
}
@@ -2311,7 +2318,7 @@ void Document::SetLexInterface(std::unique_ptr<LexInterface> pLexInterface) noex
int SCI_METHOD Document::SetLineState(Sci_Position line, int state) {
const int statePrevious = States()->SetLineState(line, state);
if (state != statePrevious) {
- const DocModification mh(SC_MOD_CHANGELINESTATE, LineStart(line), 0, 0, nullptr,
+ const DocModification mh(ModificationFlags::ChangeLineState, LineStart(line), 0, 0, nullptr,
static_cast<Sci::Line>(line));
NotifyModified(mh);
}
@@ -2327,7 +2334,7 @@ Sci::Line Document::GetMaxLineState() const noexcept {
}
void SCI_METHOD Document::ChangeLexerState(Sci_Position start, Sci_Position end) {
- const DocModification mh(SC_MOD_LEXERSTATE, start,
+ const DocModification mh(ModificationFlags::LexerState, start,
end-start, 0, 0, 0);
NotifyModified(mh);
}
@@ -2340,20 +2347,20 @@ StyledText Document::MarginStyledText(Sci::Line line) const noexcept {
void Document::MarginSetText(Sci::Line line, const char *text) {
Margins()->SetText(line, text);
- const DocModification mh(SC_MOD_CHANGEMARGIN, LineStart(line),
+ const DocModification mh(ModificationFlags::ChangeMargin, LineStart(line),
0, 0, 0, line);
NotifyModified(mh);
}
void Document::MarginSetStyle(Sci::Line line, int style) {
Margins()->SetStyle(line, style);
- NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line),
+ NotifyModified(DocModification(ModificationFlags::ChangeMargin, LineStart(line),
0, 0, 0, line));
}
void Document::MarginSetStyles(Sci::Line line, const unsigned char *styles) {
Margins()->SetStyles(line, styles);
- NotifyModified(DocModification(SC_MOD_CHANGEMARGIN, LineStart(line),
+ NotifyModified(DocModification(ModificationFlags::ChangeMargin, LineStart(line),
0, 0, 0, line));
}
@@ -2376,7 +2383,7 @@ void Document::AnnotationSetText(Sci::Line line, const char *text) {
const Sci::Line linesBefore = AnnotationLines(line);
Annotations()->SetText(line, text);
const int linesAfter = AnnotationLines(line);
- DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line),
+ DocModification mh(ModificationFlags::ChangeAnnotation, LineStart(line),
0, 0, 0, line);
mh.annotationLinesAdded = linesAfter - linesBefore;
NotifyModified(mh);
@@ -2386,7 +2393,7 @@ void Document::AnnotationSetText(Sci::Line line, const char *text) {
void Document::AnnotationSetStyle(Sci::Line line, int style) {
if (line >= 0 && line < LinesTotal()) {
Annotations()->SetStyle(line, style);
- const DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line),
+ const DocModification mh(ModificationFlags::ChangeAnnotation, LineStart(line),
0, 0, 0, line);
NotifyModified(mh);
}
@@ -2419,7 +2426,7 @@ StyledText Document::EOLAnnotationStyledText(Sci::Line line) const noexcept {
void Document::EOLAnnotationSetText(Sci::Line line, const char *text) {
if (line >= 0 && line < LinesTotal()) {
EOLAnnotations()->SetText(line, text);
- const DocModification mh(SC_MOD_CHANGEEOLANNOTATION, LineStart(line),
+ const DocModification mh(ModificationFlags::ChangeEOLAnnotation, LineStart(line),
0, 0, 0, line);
NotifyModified(mh);
}
@@ -2428,7 +2435,7 @@ void Document::EOLAnnotationSetText(Sci::Line line, const char *text) {
void Document::EOLAnnotationSetStyle(Sci::Line line, int style) {
if (line >= 0 && line < LinesTotal()) {
EOLAnnotations()->SetStyle(line, style);
- const DocModification mh(SC_MOD_CHANGEEOLANNOTATION, LineStart(line),
+ const DocModification mh(ModificationFlags::ChangeEOLAnnotation, LineStart(line),
0, 0, 0, line);
NotifyModified(mh);
}
@@ -2454,7 +2461,7 @@ void SCI_METHOD Document::DecorationFillRange(Sci_Position position, int value,
const FillResult<Sci::Position> fr = decorations->FillRange(
position, value, fillLength);
if (fr.changed) {
- const DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER,
+ const DocModification mh(ModificationFlags::ChangeIndicator | ModificationFlags::User,
fr.position, fr.fillLength);
NotifyModified(mh);
}
@@ -2493,9 +2500,9 @@ void Document::NotifySavePoint(bool atSavePoint) {
}
void Document::NotifyModified(DocModification mh) {
- if (mh.modificationType & SC_MOD_INSERTTEXT) {
+ if (FlagSet(mh.modificationType, ModificationFlags::InsertText)) {
decorations->InsertSpace(mh.position, mh.length);
- } else if (mh.modificationType & SC_MOD_DELETETEXT) {
+ } else if (FlagSet(mh.modificationType, ModificationFlags::DeleteText)) {
decorations->DeleteRange(mh.position, mh.length);
}
for (const WatcherWithUserData &watcher : watchers) {
@@ -2722,7 +2729,7 @@ public:
~BuiltinRegex() override = default;
Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
- bool caseSensitive, bool word, bool wordStart, int flags,
+ bool caseSensitive, bool word, bool wordStart, FindOption flags,
Sci::Position *length) override;
const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) override;
@@ -3144,7 +3151,7 @@ Sci::Position Cxx11RegexFindText(const Document *doc, Sci::Position minPos, Sci:
search.Clear();
bool matched = false;
- if (SC_CP_UTF8 == doc->dbcsCodePage) {
+ if (CpUtf8 == doc->dbcsCodePage) {
const std::wstring ws = WStringFromUTF8(s);
std::wregex regexp;
regexp.assign(ws, flagsRe);
@@ -3181,11 +3188,11 @@ Sci::Position Cxx11RegexFindText(const Document *doc, Sci::Position minPos, Sci:
}
Sci::Position BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
- bool caseSensitive, bool, bool, int flags,
+ bool caseSensitive, bool, bool, FindOption flags,
Sci::Position *length) {
#ifndef NO_CXX11_REGEX
- if (flags & SCFIND_CXX11REGEX) {
+ if (FlagSet(flags, FindOption::Cxx11RegEx)) {
return Cxx11RegexFindText(doc, minPos, maxPos, s,
caseSensitive, length, search);
}
@@ -3193,7 +3200,7 @@ Sci::Position BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::P
const RESearchRange resr(doc, minPos, maxPos);
- const bool posix = (flags & SCFIND_POSIX) != 0;
+ const bool posix = FlagSet(flags, FindOption::Posix);
const char *errmsg = search.Compile(s, *length, caseSensitive, posix);
if (errmsg) {
@@ -3320,7 +3327,7 @@ const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text,
#ifndef SCI_OWNREGEX
-RegexSearchBase *Scintilla::CreateRegexSearch(CharClassify *charClassTable) {
+RegexSearchBase *Scintilla::Internal::CreateRegexSearch(CharClassify *charClassTable) {
return new BuiltinRegex(charClassTable);
}
diff --git a/src/Document.h b/src/Document.h
index cbb91e574..5c9840463 100644
--- a/src/Document.h
+++ b/src/Document.h
@@ -8,7 +8,7 @@
#ifndef DOCUMENT_H
#define DOCUMENT_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class DocWatcher;
class DocModification;
@@ -93,7 +93,7 @@ public:
virtual ~RegexSearchBase() {}
virtual Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
- bool caseSensitive, bool word, bool wordStart, int flags, Sci::Position *length) = 0;
+ bool caseSensitive, bool word, bool wordStart, Scintilla::FindOption flags, Sci::Position *length) = 0;
///@return String with the substitutions, must remain valid until the next call or destruction
virtual const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) = 0;
@@ -164,22 +164,10 @@ public:
bool isEnabled;
};
-constexpr int LevelNumber(int level) noexcept {
- return level & SC_FOLDLEVELNUMBERMASK;
-}
-
-constexpr bool LevelIsHeader(int level) noexcept {
- return (level & SC_FOLDLEVELHEADERFLAG) == SC_FOLDLEVELHEADERFLAG;
-}
-
-constexpr bool LevelIsWhitespace(int level) noexcept {
- return (level & SC_FOLDLEVELWHITEFLAG) == SC_FOLDLEVELWHITEFLAG;
-}
-
class LexInterface {
protected:
Document *pdoc;
- ILexer5 *instance;
+ Scintilla::ILexer5 *instance;
bool performingStyle; ///< Prevent reentrance
public:
explicit LexInterface(Document *pdoc_) noexcept : pdoc(pdoc_), instance(nullptr), performingStyle(false) {
@@ -187,7 +175,7 @@ public:
virtual ~LexInterface() {
}
void Colourise(Sci::Position start, Sci::Position end);
- virtual int LineEndTypesSupported();
+ virtual Scintilla::LineEndType LineEndTypesSupported();
bool UseContainerLexing() const noexcept {
return instance == nullptr;
}
@@ -220,7 +208,7 @@ public:
/**
*/
-class Document : PerLine, public IDocument, public ILoader {
+class Document : PerLine, public Scintilla::IDocument, public Scintilla::ILoader {
public:
/** Used to pair watcher pointer with user data. */
@@ -280,10 +268,10 @@ public:
}
};
- int eolMode;
+ Scintilla::EndOfLine eolMode;
/// Can also be SC_CP_UTF8 to enable UTF-8 mode
int dbcsCodePage;
- int lineEndBitSet;
+ Scintilla::LineEndType lineEndBitSet;
int tabInChars;
int indentInChars;
int actualIndentInChars;
@@ -294,7 +282,7 @@ public:
std::unique_ptr<IDecorationList> decorations;
- Document(int options);
+ Document(Scintilla::DocumentOption options);
// Deleted so Document objects can not be copied.
Document(const Document &) = delete;
Document(Document &&) = delete;
@@ -311,14 +299,14 @@ public:
void InsertLines(Sci::Line line, Sci::Line lines) override;
void RemoveLine(Sci::Line line) override;
- int LineEndTypesSupported() const;
+ Scintilla::LineEndType LineEndTypesSupported() const;
bool SetDBCSCodePage(int dbcsCodePage_);
- int GetLineEndTypesAllowed() const noexcept { return cb.GetLineEndTypes(); }
- bool SetLineEndTypesAllowed(int lineEndBitSet_);
- int GetLineEndTypesActive() const noexcept { return cb.GetLineEndTypes(); }
+ Scintilla::LineEndType GetLineEndTypesAllowed() const noexcept { return cb.GetLineEndTypes(); }
+ bool SetLineEndTypesAllowed(Scintilla::LineEndType lineEndBitSet_);
+ Scintilla::LineEndType GetLineEndTypesActive() const noexcept { return cb.GetLineEndTypes(); }
int SCI_METHOD Version() const override {
- return dvRelease4;
+ return Scintilla::dvRelease4;
}
void SCI_METHOD SetErrorStatus(int status) override;
@@ -387,12 +375,12 @@ public:
Sci::Position CountUTF16(Sci::Position startPos, Sci::Position endPos) const noexcept;
Sci::Position FindColumn(Sci::Line line, Sci::Position column);
void Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop);
- static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
- void ConvertLineEnds(int eolModeSet);
+ static std::string TransformLineEnds(const char *s, size_t len, Scintilla::EndOfLine eolModeWanted);
+ void ConvertLineEnds(Scintilla::EndOfLine eolModeSet);
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
bool IsReadOnly() const noexcept { return cb.IsReadOnly(); }
bool IsLarge() const noexcept { return cb.IsLarge(); }
- int Options() const noexcept;
+ Scintilla::DocumentOption Options() const noexcept;
void DelChar(Sci::Position pos);
void DelCharBack(Sci::Position pos);
@@ -423,14 +411,15 @@ public:
bool IsLineEndPosition(Sci::Position position) const;
bool IsPositionInLineEnd(Sci::Position position) const;
Sci::Position VCHomePosition(Sci::Position position) const;
- Sci::Position IndexLineStart(Sci::Line line, int lineCharacterIndex) const noexcept;
- Sci::Line LineFromPositionIndex(Sci::Position pos, int lineCharacterIndex) const noexcept;
+ Sci::Position IndexLineStart(Sci::Line line, Scintilla::LineCharacterIndexType lineCharacterIndex) const noexcept;
+ Sci::Line LineFromPositionIndex(Sci::Position pos, Scintilla::LineCharacterIndexType lineCharacterIndex) const noexcept;
Sci::Line LineFromPositionAfter(Sci::Line line, Sci::Position length) const noexcept;
int SCI_METHOD SetLevel(Sci_Position line, int level) override;
int SCI_METHOD GetLevel(Sci_Position line) const override;
+ Scintilla::FoldLevel GetFoldLevel(Sci_Position line) const;
void ClearLevels();
- Sci::Line GetLastChild(Sci::Line lineParent, int level=-1, Sci::Line lastLine=-1);
+ Sci::Line GetLastChild(Sci::Line lineParent, std::optional<Scintilla::FoldLevel> level = {}, Sci::Line lastLine = -1);
Sci::Line GetFoldParent(Sci::Line line) const;
void GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine);
@@ -450,11 +439,11 @@ public:
bool MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const;
bool HasCaseFolder() const noexcept;
void SetCaseFolder(std::unique_ptr<CaseFolder> pcf_) noexcept;
- Sci::Position FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, int flags, Sci::Position *length);
+ Sci::Position FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, Scintilla::FindOption flags, Sci::Position *length);
const char *SubstituteByPosition(const char *text, Sci::Position *length);
- int LineCharacterIndex() const noexcept;
- void AllocateLineCharacterIndex(int lineCharacterIndex);
- void ReleaseLineCharacterIndex(int lineCharacterIndex);
+ Scintilla::LineCharacterIndexType LineCharacterIndex() const noexcept;
+ void AllocateLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
+ void ReleaseLineCharacterIndex(Scintilla::LineCharacterIndexType lineCharacterIndex);
Sci::Line LinesTotal() const noexcept;
void SetDefaultCharClasses(bool includeWordClass);
@@ -552,18 +541,18 @@ public:
*/
class DocModification {
public:
- int modificationType;
+ Scintilla::ModificationFlags modificationType;
Sci::Position position;
Sci::Position length;
Sci::Line linesAdded; /**< Negative if lines deleted. */
const char *text; /**< Only valid for changes to text, not for changes to style. */
Sci::Line line;
- int foldLevelNow;
- int foldLevelPrev;
+ Scintilla::FoldLevel foldLevelNow;
+ Scintilla::FoldLevel foldLevelPrev;
Sci::Line annotationLinesAdded;
Sci::Position token;
- DocModification(int modificationType_, Sci::Position position_=0, Sci::Position length_=0,
+ DocModification(Scintilla::ModificationFlags modificationType_, Sci::Position position_=0, Sci::Position length_=0,
Sci::Line linesAdded_=0, const char *text_=nullptr, Sci::Line line_=0) noexcept :
modificationType(modificationType_),
position(position_),
@@ -571,20 +560,20 @@ public:
linesAdded(linesAdded_),
text(text_),
line(line_),
- foldLevelNow(0),
- foldLevelPrev(0),
+ foldLevelNow(Scintilla::FoldLevel::None),
+ foldLevelPrev(Scintilla::FoldLevel::None),
annotationLinesAdded(0),
token(0) {}
- DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) noexcept :
+ DocModification(Scintilla::ModificationFlags modificationType_, const Action &act, Sci::Line linesAdded_=0) noexcept :
modificationType(modificationType_),
position(act.position),
length(act.lenData),
linesAdded(linesAdded_),
text(act.data.get()),
line(0),
- foldLevelNow(0),
- foldLevelPrev(0),
+ foldLevelNow(Scintilla::FoldLevel::None),
+ foldLevelPrev(Scintilla::FoldLevel::None),
annotationLinesAdded(0),
token(0) {}
};
@@ -603,7 +592,7 @@ public:
virtual void NotifyDeleted(Document *doc, void *userData) noexcept = 0;
virtual void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos) = 0;
virtual void NotifyLexerChanged(Document *doc, void *userData) = 0;
- virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0;
+ virtual void NotifyErrorOccurred(Document *doc, void *userData, Scintilla::Status status) = 0;
};
}
diff --git a/src/EditModel.cxx b/src/EditModel.cxx
index 35a2bc549..e9186a026 100644
--- a/src/EditModel.cxx
+++ b/src/EditModel.cxx
@@ -21,14 +21,14 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.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"
@@ -38,7 +38,6 @@
#include "RunStyles.h"
#include "ContractionState.h"
#include "CellBuffer.h"
-#include "KeyMap.h"
#include "Indicator.h"
#include "LineMarker.h"
#include "Style.h"
@@ -53,6 +52,7 @@
#include "EditModel.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
Caret::Caret() noexcept :
active(false), on(false), period(500) {}
@@ -64,19 +64,19 @@ EditModel::EditModel() : braces{} {
posDrag = SelectionPosition(Sci::invalidPosition);
braces[0] = Sci::invalidPosition;
braces[1] = Sci::invalidPosition;
- bracesMatchStyle = STYLE_BRACEBAD;
+ bracesMatchStyle = StyleBraceBad;
highlightGuideColumn = 0;
hasFocus = false;
primarySelection = true;
- imeInteraction = IMEInteraction::windowed;
- bidirectional = Bidirectional::bidiDisabled;
- foldFlags = 0;
- foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN;
+ imeInteraction = IMEInteraction::Windowed;
+ bidirectional = Bidirectional::Disabled;
+ foldFlags = FoldFlag::None;
+ foldDisplayTextStyle = FoldDisplayTextStyle::Hidden;
hotspot = Range(Sci::invalidPosition);
hotspotSingleLine = true;
hoverIndicatorPos = Sci::invalidPosition;
wrapWidth = LineLayout::wrapWidthInfinite;
- pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);
+ pdoc = new Document(DocumentOption::Default);
pdoc->AddRef();
pcs = ContractionStateCreate(pdoc->IsLarge());
}
@@ -87,12 +87,12 @@ EditModel::~EditModel() {
}
bool EditModel::BidirectionalEnabled() const noexcept {
- return (bidirectional != Bidirectional::bidiDisabled) &&
- (SC_CP_UTF8 == pdoc->dbcsCodePage);
+ return (bidirectional != Bidirectional::Disabled) &&
+ (CpUtf8 == pdoc->dbcsCodePage);
}
bool EditModel::BidirectionalR2L() const noexcept {
- return bidirectional == Bidirectional::bidiR2L;
+ return bidirectional == Bidirectional::R2L;
}
void EditModel::SetDefaultFoldDisplayText(const char *text) {
@@ -104,7 +104,7 @@ const char *EditModel::GetDefaultFoldDisplayText() const noexcept {
}
const char *EditModel::GetFoldDisplayText(Sci::Line lineDoc) const noexcept {
- if (foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_HIDDEN || pcs->GetExpanded(lineDoc)) {
+ if (foldDisplayTextStyle == FoldDisplayTextStyle::Hidden || pcs->GetExpanded(lineDoc)) {
return nullptr;
}
diff --git a/src/EditModel.h b/src/EditModel.h
index e2f3e20e0..16a3d1c9f 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -8,7 +8,7 @@
#ifndef EDITMODEL_H
#define EDITMODEL_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
*/
@@ -37,12 +37,11 @@ public:
Selection sel;
bool primarySelection;
- enum class IMEInteraction { windowed, internal } imeInteraction;
- enum class CharacterSource { directInput, tentativeInput, imeResult };
- enum class Bidirectional { bidiDisabled, bidiL2R, bidiR2L } bidirectional;
+ Scintilla::IMEInteraction imeInteraction;
+ Scintilla::Bidirectional bidirectional;
- int foldFlags;
- int foldDisplayTextStyle;
+ Scintilla::FoldFlag foldFlags;
+ Scintilla::FoldDisplayTextStyle foldDisplayTextStyle;
UniqueString defaultFoldDisplayText;
std::unique_ptr<IContractionState> pcs;
// Hotspot support
diff --git a/src/EditView.cxx b/src/EditView.cxx
index c71c3ce60..3ba7b8560 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -25,14 +25,16 @@
#include <memory>
#include <chrono>
+#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 "CharacterType.h"
#include "CharacterCategoryMap.h"
#include "Position.h"
@@ -61,14 +63,15 @@
#include "ElapsedPeriod.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
PrintParameters::PrintParameters() noexcept {
magnification = 0;
- colourMode = SC_PRINT_NORMAL;
- wrapState = WrapMode::word;
+ colourMode = PrintOption::Normal;
+ wrapState = Wrap::Word;
}
-namespace Scintilla {
+namespace Scintilla::Internal {
bool ValidStyledText(const ViewStyle &vs, size_t styleOffset, const StyledText &st) noexcept {
if (st.multipleStyles) {
@@ -174,12 +177,12 @@ EditView::EditView() {
hideSelection = false;
drawOverstrikeCaret = true;
bufferedDraw = true;
- phasesDraw = PhasesDraw::two;
+ phasesDraw = PhasesDraw::Two;
lineWidthMaxSeen = 0;
additionalCaretsBlink = true;
additionalCaretsVisible = true;
imeCaretBlockOverride = false;
- llc.SetLevel(LineLayoutCache::Cache::caret);
+ llc.SetLevel(LineCache::Caret);
posCache.SetSize(0x400);
tabArrowHeight = 4;
customDrawTabArrow = nullptr;
@@ -189,7 +192,7 @@ EditView::EditView() {
EditView::~EditView() = default;
bool EditView::SetTwoPhaseDraw(bool twoPhaseDraw) noexcept {
- const PhasesDraw phasesDrawNew = twoPhaseDraw ? PhasesDraw::two : PhasesDraw::one;
+ const PhasesDraw phasesDrawNew = twoPhaseDraw ? PhasesDraw::Two : PhasesDraw::One;
const bool redraw = phasesDraw != phasesDrawNew;
phasesDraw = phasesDrawNew;
return redraw;
@@ -203,7 +206,7 @@ bool EditView::SetPhasesDraw(int phases) noexcept {
}
bool EditView::LinesOverlap() const noexcept {
- return phasesDraw == PhasesDraw::multiple;
+ return phasesDraw == PhasesDraw::Multiple;
}
void EditView::ClearAllTabstops() noexcept {
@@ -285,7 +288,7 @@ static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid,
}
// Draw the arrow head if needed
- if (vsDraw.tabDrawMode == TabDrawMode::longArrow) {
+ if (vsDraw.tabDrawMode == TabDrawMode::LongArrow) {
XYPOSITION ydiff = std::floor(rcTab.Height() / 2.0f);
XYPOSITION xhead = rightStroke - ydiff;
if (xhead <= rcTab.left) {
@@ -307,12 +310,12 @@ void EditView::RefreshPixMaps(Surface *surfaceWindow, const ViewStyle &vsDraw) {
pixmapIndentGuide = surfaceWindow->AllocatePixMap(1, vsDraw.lineHeight + 1);
pixmapIndentGuideHighlight = surfaceWindow->AllocatePixMap(1, vsDraw.lineHeight + 1);
const PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vsDraw.lineHeight);
- pixmapIndentGuide->FillRectangle(rcIG, vsDraw.styles[STYLE_INDENTGUIDE].back);
- pixmapIndentGuideHighlight->FillRectangle(rcIG, vsDraw.styles[STYLE_BRACELIGHT].back);
+ pixmapIndentGuide->FillRectangle(rcIG, vsDraw.styles[StyleIndentGuide].back);
+ pixmapIndentGuideHighlight->FillRectangle(rcIG, vsDraw.styles[StyleBraceLight].back);
for (int stripe = 1; stripe < vsDraw.lineHeight + 1; stripe += 2) {
const PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1);
- pixmapIndentGuide->FillRectangle(rcPixel, vsDraw.styles[STYLE_INDENTGUIDE].fore);
- pixmapIndentGuideHighlight->FillRectangle(rcPixel, vsDraw.styles[STYLE_BRACELIGHT].fore);
+ pixmapIndentGuide->FillRectangle(rcPixel, vsDraw.styles[StyleIndentGuide].fore);
+ pixmapIndentGuideHighlight->FillRectangle(rcPixel, vsDraw.styles[StyleBraceLight].fore);
}
pixmapIndentGuide->FlushDrawing();
pixmapIndentGuideHighlight->FlushDrawing();
@@ -420,7 +423,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt
if (ll->validity == LineLayout::ValidLevel::invalid) {
ll->widthLine = LineLayout::wrapWidthInfinite;
ll->lines = 1;
- if (vstyle.edgeState == EDGE_BACKGROUND) {
+ if (vstyle.edgeState == EdgeVisualStyle::Background) {
Sci::Position edgePosition = model.pdoc->FindColumn(line, vstyle.theEdge.column);
if (edgePosition >= posLineStart) {
edgePosition -= posLineStart;
@@ -471,7 +474,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt
} else {
if (representationWidth <= 0.0) {
XYPOSITION positionsRepr[256]; // Should expand when needed
- posCache.MeasureWidths(surface, vstyle, STYLE_CONTROLCHAR, ts.representation->stringRep.c_str(),
+ posCache.MeasureWidths(surface, vstyle, StyleControlChar, ts.representation->stringRep.c_str(),
static_cast<unsigned int>(ts.representation->stringRep.length()), positionsRepr, model.pdoc);
representationWidth = positionsRepr[ts.representation->stringRep.length() - 1] + vstyle.ctrlCharPadding;
}
@@ -511,25 +514,25 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt
// Simple common case where line does not need wrapping.
ll->lines = 1;
} else {
- if (vstyle.wrap.visualFlags & SC_WRAPVISUALFLAG_END) {
+ if (FlagSet(vstyle.wrap.visualFlags, WrapVisualFlag::End)) {
width -= static_cast<int>(vstyle.aveCharWidth); // take into account the space for end wrap mark
}
XYPOSITION wrapAddIndent = 0; // This will be added to initial indent of line
switch (vstyle.wrap.indentMode) {
- case SC_WRAPINDENT_FIXED:
+ case WrapIndentMode::Fixed:
wrapAddIndent = vstyle.wrap.visualStartIndent * vstyle.aveCharWidth;
break;
- case SC_WRAPINDENT_INDENT:
+ case WrapIndentMode::Indent:
wrapAddIndent = model.pdoc->IndentSize() * vstyle.spaceWidth;
break;
- case SC_WRAPINDENT_DEEPINDENT:
+ case WrapIndentMode::DeepIndent:
wrapAddIndent = model.pdoc->IndentSize() * 2 * vstyle.spaceWidth;
break;
- default: // No additional indent for SC_WRAPINDENT_FIXED
+ default: // No additional indent for WrapIndentMode::Fixed
break;
}
ll->wrapIndent = wrapAddIndent;
- if (vstyle.wrap.indentMode != SC_WRAPINDENT_FIXED) {
+ if (vstyle.wrap.indentMode != WrapIndentMode::Fixed) {
for (int i = 0; i < ll->numCharsInLine; i++) {
if (!IsSpaceOrTab(ll->chars[i])) {
ll->wrapIndent += ll->positions[i]; // Add line indent
@@ -541,7 +544,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt
if (ll->wrapIndent > width - static_cast<int>(vstyle.aveCharWidth) * 15)
ll->wrapIndent = wrapAddIndent;
// Check for wrapIndent minimum
- if ((vstyle.wrap.visualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < vstyle.aveCharWidth))
+ if ((FlagSet(vstyle.wrap.visualFlags, WrapVisualFlag::Start)) && (ll->wrapIndent < vstyle.aveCharWidth))
ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual
ll->lines = 0;
// Calculate line start positions based upon width.
@@ -573,12 +576,12 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt
continue;
}
if (p > 0) {
- if (vstyle.wrap.state == WrapMode::character) {
+ if (vstyle.wrap.state == Wrap::Char) {
lastGoodBreak = model.pdoc->MovePositionOutsideChar(p + posLineStart, -1)
- posLineStart;
p = model.pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart;
continue;
- } else if ((vstyle.wrap.state == WrapMode::word) && (ll->styles[p] != ll->styles[p - 1])) {
+ } else if ((vstyle.wrap.state == Wrap::Word) && (ll->styles[p] != ll->styles[p - 1])) {
lastGoodBreak = p;
} else if (IsSpaceOrTab(ll->chars[p - 1]) && !IsSpaceOrTab(ll->chars[p])) {
lastGoodBreak = p;
@@ -832,27 +835,27 @@ ColourRGBA SelectionBackground(const EditModel &model, const ViewStyle &vsDraw,
if (inSelection == InSelection::inNone)
return bugColour; // Not selected is a bug
- int element = SC_ELEMENT_SELECTION_BACK;
+ Element element = Element::SelectionBack;
if (inSelection == InSelection::inAdditional)
- element = SC_ELEMENT_SELECTION_ADDITIONAL_BACK;
+ element = Element::SelectionAdditionalBack;
if (!model.primarySelection)
- element = SC_ELEMENT_SELECTION_SECONDARY_BACK;
- if (!model.hasFocus && vsDraw.ElementColour(SC_ELEMENT_SELECTION_NO_FOCUS_BACK))
- element = SC_ELEMENT_SELECTION_NO_FOCUS_BACK;
+ element = Element::SelectionSecondaryBack;
+ if (!model.hasFocus && vsDraw.ElementColour(Element::SelectionNoFocusBack))
+ element = Element::SelectionNoFocusBack;
return vsDraw.ElementColour(element).value_or(bugColour);
}
std::optional<ColourRGBA> SelectionForeground(const EditModel &model, const ViewStyle &vsDraw, InSelection inSelection) {
if (inSelection == InSelection::inNone)
return {};
- int element = SC_ELEMENT_SELECTION_TEXT;
+ Element element = Element::SelectionText;
if (inSelection == InSelection::inAdditional)
- element = SC_ELEMENT_SELECTION_ADDITIONAL_TEXT;
+ element = Element::SelectionAdditionalText;
if (!model.primarySelection) // Secondary selection
- element = SC_ELEMENT_SELECTION_SECONDARY_TEXT;
+ element = Element::SelectionSecondaryText;
if (!model.hasFocus) {
- if (vsDraw.ElementColour(SC_ELEMENT_SELECTION_NO_FOCUS_TEXT)) {
- element = SC_ELEMENT_SELECTION_NO_FOCUS_TEXT;
+ if (vsDraw.ElementColour(Element::SelectionNoFocusText)) {
+ element = Element::SelectionNoFocusText;
} else {
return {};
}
@@ -864,16 +867,16 @@ std::optional<ColourRGBA> SelectionForeground(const EditModel &model, const View
static ColourRGBA TextBackground(const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
std::optional<ColourRGBA> background, InSelection inSelection, bool inHotspot, int styleMain, Sci::Position i) {
- if (inSelection && (vsDraw.selection.layer == Layer::base)) {
+ if (inSelection && (vsDraw.selection.layer == Layer::Base)) {
return SelectionBackground(model, vsDraw, inSelection).Opaque();
}
- if ((vsDraw.edgeState == EDGE_BACKGROUND) &&
+ if ((vsDraw.edgeState == EdgeVisualStyle::Background) &&
(i >= ll->edgeColumn) &&
(i < ll->numCharsBeforeEOL))
return vsDraw.theEdge.colour;
- if (inHotspot && vsDraw.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE_BACK))
- return vsDraw.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE_BACK)->Opaque();
- if (background && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) {
+ if (inHotspot && vsDraw.ElementColour(Element::HotSpotActiveBack))
+ return vsDraw.ElementColour(Element::HotSpotActiveBack)->Opaque();
+ if (background && (styleMain != StyleBraceLight) && (styleMain != StyleBraceBad)) {
return *background;
} else {
return vsDraw.styles[styleMain].back;
@@ -895,8 +898,8 @@ static void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle r
if (fillBackground) {
surface->FillRectangleAligned(rcSegment, Fill(textBack));
}
- const Font *ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font.get();
- const int normalCharHeight = static_cast<int>(std::ceil(vsDraw.styles[STYLE_CONTROLCHAR].capitalHeight));
+ const Font *ctrlCharsFont = vsDraw.styles[StyleControlChar].font.get();
+ const int normalCharHeight = static_cast<int>(std::ceil(vsDraw.styles[StyleControlChar].capitalHeight));
PRectangle rcCChar = rcSegment;
rcCChar.left = rcCChar.left + 1;
rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight;
@@ -914,12 +917,12 @@ static void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle r
}
static void DrawCaretLineFramed(Surface *surface, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine, int subLine) {
- const std::optional<ColourRGBA> caretlineBack = vsDraw.ElementColour(SC_ELEMENT_CARET_LINE_BACK);
+ const std::optional<ColourRGBA> caretlineBack = vsDraw.ElementColour(Element::CaretLineBack);
if (!caretlineBack) {
return;
}
- const ColourRGBA colourFrame = (vsDraw.caretLine.layer == Layer::base) ?
+ const ColourRGBA colourFrame = (vsDraw.caretLine.layer == Layer::Base) ?
caretlineBack->Opaque() : *caretlineBack;
const int width = vsDraw.GetFrameWidth();
@@ -927,7 +930,7 @@ static void DrawCaretLineFramed(Surface *surface, const ViewStyle &vsDraw, const
// Avoid double drawing the corners by removing the left and right sides when drawing top and bottom borders
const PRectangle rcWithoutLeftRight = rcLine.Inset(Point(width, 0.0));
- if (subLine == 0 || ll->wrapIndent == 0 || vsDraw.caretLine.layer != Layer::base) {
+ if (subLine == 0 || ll->wrapIndent == 0 || vsDraw.caretLine.layer != Layer::Base) {
// Left
surface->FillRectangleAligned(Side(rcLine, Edge::left, width), colourFrame);
}
@@ -935,7 +938,7 @@ static void DrawCaretLineFramed(Surface *surface, const ViewStyle &vsDraw, const
// Top
surface->FillRectangleAligned(Side(rcWithoutLeftRight, Edge::top, width), colourFrame);
}
- if (subLine == ll->lines - 1 || vsDraw.caretLine.layer != Layer::base) {
+ if (subLine == ll->lines - 1 || vsDraw.caretLine.layer != Layer::Base) {
// Right
surface->FillRectangleAligned(Side(rcLine, Edge::right, width), colourFrame);
}
@@ -966,7 +969,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
rcSegment.right = xEol + xStart + virtualSpace;
const ColourRGBA backgroundFill = background.value_or(vsDraw.styles[ll->styles[ll->numCharsInLine]].back);
surface->FillRectangleAligned(rcSegment, backgroundFill);
- if (!hideSelection && (vsDraw.selection.layer == Layer::base)) {
+ if (!hideSelection && (vsDraw.selection.layer == Layer::Base)) {
const SelectionSegment virtualSpaceRange(SelectionPosition(model.pdoc->LineEnd(line)),
SelectionPosition(model.pdoc->LineEnd(line),
model.sel.VirtualSpaceFor(model.pdoc->LineEnd(line))));
@@ -1021,7 +1024,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
const std::optional<ColourRGBA> selectionFore = SelectionForeground(model, vsDraw, eolInSelection);
const ColourRGBA textFore = selectionFore.value_or(vsDraw.styles[styleMain].fore);
if (eolInSelection && (line < model.pdoc->LinesTotal() - 1)) {
- if (vsDraw.selection.layer == Layer::base) {
+ if (vsDraw.selection.layer == Layer::Base) {
surface->FillRectangleAligned(rcSegment, Fill(selectionBack.Opaque()));
} else {
surface->FillRectangleAligned(rcSegment, Fill(textBack));
@@ -1031,12 +1034,12 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
}
const bool drawEOLSelection = eolInSelection && (line < model.pdoc->LinesTotal() - 1);
ColourRGBA blobText = textBack;
- if (drawEOLSelection && (vsDraw.selection.layer == Layer::under)) {
+ if (drawEOLSelection && (vsDraw.selection.layer == Layer::UnderText)) {
surface->FillRectangleAligned(rcSegment, selectionBack);
blobText = textBack.MixedWith(selectionBack, selectionBack.GetAlphaComponent());
}
- DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, blobText, textFore, phasesDraw == PhasesDraw::one);
- if (drawEOLSelection && (vsDraw.selection.layer == Layer::over)) {
+ DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, blobText, textFore, phasesDraw == PhasesDraw::One);
+ if (drawEOLSelection && (vsDraw.selection.layer == Layer::OverText)) {
surface->FillRectangleAligned(rcSegment, selectionBack);
}
}
@@ -1046,7 +1049,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
rcSegment.left = xEol + xStart + virtualSpace + blobsWidth;
rcSegment.right = rcSegment.left + vsDraw.aveCharWidth;
- if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::base)) {
+ if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::Base)) {
surface->FillRectangleAligned(rcSegment, Fill(selectionBack.Opaque()));
} else {
if (background) {
@@ -1056,9 +1059,9 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
} else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) {
surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[ll->styles[ll->numCharsInLine]].back));
} else {
- surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[STYLE_DEFAULT].back));
+ surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[StyleDefault].back));
}
- if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::base)) {
+ if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::Base)) {
surface->FillRectangleAligned(rcSegment, selectionBack);
}
}
@@ -1068,7 +1071,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
rcSegment.left = rcLine.left;
rcSegment.right = rcLine.right;
- const bool drawEOLAnnotationStyledText = (vsDraw.eolAnnotationVisible != EOLANNOTATION_HIDDEN) && model.pdoc->EOLAnnotationStyledText(line).text;
+ const bool drawEOLAnnotationStyledText = (vsDraw.eolAnnotationVisible != EOLAnnotationVisible::Hidden) && model.pdoc->EOLAnnotationStyledText(line).text;
const bool fillRemainder = (!lastSubLine || (!model.GetFoldDisplayText(line) && !drawEOLAnnotationStyledText));
if (fillRemainder) {
// Fill the remainder of the line
@@ -1078,20 +1081,20 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
bool drawWrapMarkEnd = false;
if (subLine + 1 < ll->lines) {
- if (vsDraw.wrap.visualFlags & SC_WRAPVISUALFLAG_END) {
+ if (FlagSet(vsDraw.wrap.visualFlags, WrapVisualFlag::End)) {
drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0;
}
if (vsDraw.IsLineFrameOpaque(model.caret.active, ll->containsCaret)) {
// Draw right of frame under marker
surface->FillRectangleAligned(Side(rcLine, Edge::right, vsDraw.GetFrameWidth()),
- vsDraw.ElementColour(SC_ELEMENT_CARET_LINE_BACK)->Opaque());
+ vsDraw.ElementColour(Element::CaretLineBack)->Opaque());
}
}
if (drawWrapMarkEnd) {
PRectangle rcPlace = rcSegment;
- if (vsDraw.wrap.visualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) {
+ if (FlagSet(vsDraw.wrap.visualFlagsLocation, WrapVisualLocation::EndByText)) {
rcPlace.left = xEol + xStart + virtualSpace;
rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
} else {
@@ -1185,9 +1188,9 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS
}
// Use indicators to highlight matching braces
- if ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACELIGHT)) ||
- (vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD))) {
- const int braceIndicator = (model.bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator;
+ if ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == StyleBraceLight)) ||
+ (vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == StyleBraceBad))) {
+ const int braceIndicator = (model.bracesMatchStyle == StyleBraceLight) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator;
if (under == vsDraw.indicators[braceIndicator].under) {
const Range rangeLine(posLineStart + lineStart, posLineEnd);
if (rangeLine.ContainsCharacter(model.braces[0])) {
@@ -1222,7 +1225,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
PRectangle rcSegment = rcLine;
const std::string_view foldDisplayText(text);
- const Font *fontText = vsDraw.styles[STYLE_FOLDDISPLAYTEXT].font.get();
+ const Font *fontText = vsDraw.styles[StyleFoldDisplayText].font.get();
const int widthFoldDisplayText = static_cast<int>(surface->WidthText(fontText, foldDisplayText));
InSelection eolInSelection = InSelection::inNone;
@@ -1238,9 +1241,9 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
const std::optional<ColourRGBA> background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
const std::optional<ColourRGBA> selectionFore = SelectionForeground(model, vsDraw, eolInSelection);
- const ColourRGBA textFore = selectionFore.value_or(vsDraw.styles[STYLE_FOLDDISPLAYTEXT].fore);
+ const ColourRGBA textFore = selectionFore.value_or(vsDraw.styles[StyleFoldDisplayText].fore);
const ColourRGBA textBack = TextBackground(model, vsDraw, ll, background, eolInSelection,
- false, STYLE_FOLDDISPLAYTEXT, -1);
+ false, StyleFoldDisplayText, -1);
if (model.trackLineWidth) {
if (rcSegment.right + 1> lineWidthMaxSeen) {
@@ -1262,7 +1265,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
}
if (FlagSet(phase, DrawPhase::text)) {
- if (phasesDraw != PhasesDraw::one) {
+ if (phasesDraw != PhasesDraw::One) {
surface->DrawTextTransparent(rcSegment, fontText,
rcSegment.top + vsDraw.maxAscent, foldDisplayText,
textFore);
@@ -1274,7 +1277,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
}
if (FlagSet(phase, DrawPhase::indicatorsFore)) {
- if (model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_BOXED) {
+ if (model.foldDisplayTextStyle == FoldDisplayTextStyle::Boxed) {
PRectangle rcBox = rcSegment;
rcBox.left = std::round(rcSegment.left);
rcBox.right = std::round(rcSegment.right);
@@ -1283,7 +1286,7 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
}
if (FlagSet(phase, DrawPhase::selectionTranslucent)) {
- if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::base)) {
+ if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::Base)) {
surface->FillRectangleAligned(rcSegment, SelectionBackground(model, vsDraw, eolInSelection));
}
}
@@ -1295,7 +1298,7 @@ void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, c
if (!lastSubLine)
return;
- if (vsDraw.eolAnnotationVisible == EOLANNOTATION_HIDDEN) {
+ if (vsDraw.eolAnnotationVisible == EOLAnnotationVisible::Hidden) {
return;
}
const StyledText stEOLAnnotation = model.pdoc->EOLAnnotationStyledText(line);
@@ -1308,16 +1311,16 @@ void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, c
PRectangle rcSegment = rcLine;
const Font *fontText = vsDraw.styles[style].font.get();
- const Surface::Ends ends = static_cast<Surface::Ends>(vsDraw.eolAnnotationVisible & 0xff);
+ const Surface::Ends ends = static_cast<Surface::Ends>(static_cast<int>(vsDraw.eolAnnotationVisible) & 0xff);
const Surface::Ends leftSide = static_cast<Surface::Ends>(static_cast<int>(ends) & 0xf);
const Surface::Ends rightSide = static_cast<Surface::Ends>(static_cast<int>(ends) & 0xf0);
XYPOSITION leftBoxSpace = 0;
XYPOSITION rightBoxSpace = 0;
- if (vsDraw.eolAnnotationVisible >= EOLANNOTATION_BOXED) {
+ if (vsDraw.eolAnnotationVisible >= EOLAnnotationVisible::Boxed) {
leftBoxSpace = 1;
rightBoxSpace = 1;
- if (vsDraw.eolAnnotationVisible != EOLANNOTATION_BOXED) {
+ if (vsDraw.eolAnnotationVisible != EOLAnnotationVisible::Boxed) {
switch (leftSide) {
case Surface::Ends::leftFlat:
leftBoxSpace = 1;
@@ -1389,7 +1392,7 @@ void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, c
// For single phase drawing, draw the text then any box over it
if (FlagSet(phase, DrawPhase::text)) {
- if (phasesDraw == PhasesDraw::one) {
+ if (phasesDraw == PhasesDraw::One) {
surface->DrawTextNoClipUTF8(rcText, fontText,
rcText.top + vsDraw.maxAscent, eolAnnotationText,
textFore, textBack);
@@ -1398,14 +1401,14 @@ void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, c
// Draw any box or stadium shape
if (FlagSet(phase, DrawPhase::indicatorsBack)) {
- if (vsDraw.eolAnnotationVisible >= EOLANNOTATION_BOXED) {
+ if (vsDraw.eolAnnotationVisible >= EOLAnnotationVisible::Boxed) {
PRectangle rcBox = rcSegment;
rcBox.left = std::round(rcSegment.left);
rcBox.right = std::round(rcSegment.right);
- if (vsDraw.eolAnnotationVisible == EOLANNOTATION_BOXED) {
+ if (vsDraw.eolAnnotationVisible == EOLAnnotationVisible::Boxed) {
surface->RectangleFrame(rcBox, Stroke(textFore));
} else {
- if (phasesDraw == PhasesDraw::one) {
+ if (phasesDraw == PhasesDraw::One) {
// Draw an outline around the text
surface->Stadium(rcBox, FillStroke(ColourRGBA(textBack, 0), textFore, 1.0), ends);
} else {
@@ -1418,7 +1421,7 @@ void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, c
// For multi-phase drawing draw the text last as transparent over any box
if (FlagSet(phase, DrawPhase::text)) {
- if (phasesDraw != PhasesDraw::one) {
+ if (phasesDraw != PhasesDraw::One) {
surface->DrawTextTransparentUTF8(rcText, fontText,
rcText.top + vsDraw.maxAscent, eolAnnotationText,
textFore);
@@ -1426,8 +1429,8 @@ void EditView::DrawEOLAnnotationText(Surface *surface, const EditModel &model, c
}
}
-static constexpr bool AnnotationBoxedOrIndented(int annotationVisible) noexcept {
- return annotationVisible == ANNOTATION_BOXED || annotationVisible == ANNOTATION_INDENTED;
+static constexpr bool AnnotationBoxedOrIndented(AnnotationVisible annotationVisible) noexcept {
+ return annotationVisible == AnnotationVisible::Boxed || annotationVisible == AnnotationVisible::Indented;
}
void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
@@ -1469,7 +1472,7 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi
}
DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText,
stAnnotation, start, lengthAnnotation, phase);
- if ((FlagSet(phase, DrawPhase::back)) && (vsDraw.annotationVisible == ANNOTATION_BOXED)) {
+ if ((FlagSet(phase, DrawPhase::back)) && (vsDraw.annotationVisible == AnnotationVisible::Boxed)) {
const ColourRGBA colourBorder = vsDraw.styles[vsDraw.annotationStyleOffset].fore;
const PRectangle rcBorder = PixelAlignOutside(rcSegment, surface->PixelDivisions());
surface->FillRectangle(Side(rcBorder, Edge::left, 1), colourBorder);
@@ -1641,7 +1644,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
rcCaret.left = std::round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caret.width;
}
- const int elementCaret = mainCaret ? SC_ELEMENT_CARET : SC_ELEMENT_CARET_ADDITIONAL;
+ const Element elementCaret = mainCaret ? Element::Caret : Element::CaretAdditional;
const ColourRGBA caretColour = *vsDraw.ElementColour(elementCaret);
//assert(caretColour.IsOpaque());
if (drawBlockCaret) {
@@ -1661,15 +1664,15 @@ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, c
bool caretActive) {
// default bgnd here..
surface->FillRectangleAligned(rcLine, Fill(background ? *background :
- vsDraw.styles[STYLE_DEFAULT].back));
+ vsDraw.styles[StyleDefault].back));
if (vsDraw.IsLineFrameOpaque(caretActive, ll->containsCaret)) {
// Draw left of frame under marker
surface->FillRectangleAligned(Side(rcLine, Edge::left, vsDraw.GetFrameWidth()),
- vsDraw.ElementColour(SC_ELEMENT_CARET_LINE_BACK)->Opaque());
+ vsDraw.ElementColour(Element::CaretLineBack)->Opaque());
}
- if (vsDraw.wrap.visualFlags & SC_WRAPVISUALFLAG_START) {
+ if (FlagSet(vsDraw.wrap.visualFlags, WrapVisualFlag::Start)) {
// draw continuation rect
PRectangle rcPlace = rcLine;
@@ -1677,7 +1680,7 @@ static void DrawWrapIndentAndMarker(Surface *surface, const ViewStyle &vsDraw, c
rcPlace.left = static_cast<XYPOSITION>(xStart);
rcPlace.right = rcPlace.left + ll->wrapIndent;
- if (vsDraw.wrap.visualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT)
+ if (FlagSet(vsDraw.wrap.visualFlagsLocation, WrapVisualLocation::StartByText))
rcPlace.left = rcPlace.right - vsDraw.aveCharWidth;
else
rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
@@ -1731,7 +1734,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
if (ll->chars[i] == '\t') {
// Tab display
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) {
- textBack = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque();
+ textBack = vsDraw.ElementColour(Element::WhiteSpaceBack)->Opaque();
}
} else {
// Blob display
@@ -1741,7 +1744,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
} else {
// Normal text display
surface->FillRectangleAligned(rcSegment, Fill(textBack));
- if (vsDraw.viewWhitespace != WhiteSpace::invisible) {
+ if (vsDraw.viewWhitespace != WhiteSpace::Invisible) {
for (int cpos = 0; cpos <= i - ts.start; cpos++) {
if (ll->chars[cpos + ts.start] == ' ') {
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) {
@@ -1751,7 +1754,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.bottom);
surface->FillRectangleAligned(rcSpace,
- vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque());
+ vsDraw.ElementColour(Element::WhiteSpaceBack)->Opaque());
}
} else {
inIndentation = false;
@@ -1767,7 +1770,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
static void DrawEdgeLine(Surface *surface, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine,
Range lineRange, int xStart) {
- if (vsDraw.edgeState == EDGE_LINE) {
+ if (vsDraw.edgeState == EdgeVisualStyle::Line) {
PRectangle rcSegment = rcLine;
const int edgeX = static_cast<int>(vsDraw.theEdge.column * vsDraw.spaceWidth);
rcSegment.left = static_cast<XYPOSITION>(edgeX + xStart);
@@ -1775,7 +1778,7 @@ static void DrawEdgeLine(Surface *surface, const ViewStyle &vsDraw, const LineLa
rcSegment.left -= ll->wrapIndent;
rcSegment.right = rcSegment.left + 1;
surface->FillRectangleAligned(rcSegment, Fill(vsDraw.theEdge.colour));
- } else if (vsDraw.edgeState == EDGE_MULTILINE) {
+ } else if (vsDraw.edgeState == EdgeVisualStyle::MultiLine) {
for (size_t edge = 0; edge < vsDraw.theMultiEdge.size(); edge++) {
if (vsDraw.theMultiEdge[edge].column >= 0) {
PRectangle rcSegment = rcLine;
@@ -1795,8 +1798,8 @@ static void DrawMarkUnderline(Surface *surface, const EditModel &model, const Vi
Sci::Line line, PRectangle rcLine) {
int marks = model.pdoc->GetMark(line);
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
- if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) &&
- (vsDraw.markers[markBit].layer == Layer::base)) {
+ if ((marks & 1) && (vsDraw.markers[markBit].markType == MarkerSymbol::Underline) &&
+ (vsDraw.markers[markBit].layer == Layer::Base)) {
PRectangle rcUnderline = rcLine;
rcUnderline.top = rcUnderline.bottom - 2;
surface->FillRectangleAligned(rcUnderline, Fill(vsDraw.markers[markBit].back));
@@ -1870,21 +1873,21 @@ static void DrawTranslucentSelection(Surface *surface, const EditModel &model, c
// Draw any translucent whole line states
static void DrawTranslucentLineState(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line line, PRectangle rcLine, int subLine, Layer layer) {
- if ((model.caret.active || vsDraw.caretLine.alwaysShow) && vsDraw.ElementColour(SC_ELEMENT_CARET_LINE_BACK) && ll->containsCaret &&
+ if ((model.caret.active || vsDraw.caretLine.alwaysShow) && vsDraw.ElementColour(Element::CaretLineBack) && ll->containsCaret &&
vsDraw.caretLine.layer == layer) {
if (vsDraw.caretLine.frame) {
DrawCaretLineFramed(surface, vsDraw, ll, rcLine, subLine);
} else {
- surface->FillRectangleAligned(rcLine, *vsDraw.ElementColour(SC_ELEMENT_CARET_LINE_BACK));
+ surface->FillRectangleAligned(rcLine, *vsDraw.ElementColour(Element::CaretLineBack));
}
}
const int marksOfLine = model.pdoc->GetMark(line);
int marksDrawnInText = marksOfLine & vsDraw.maskDrawInText;
for (int markBit = 0; (markBit < 32) && marksDrawnInText; markBit++) {
if ((marksDrawnInText & 1) && (vsDraw.markers[markBit].layer == layer)) {
- if (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) {
+ if (vsDraw.markers[markBit].markType == MarkerSymbol::Background) {
surface->FillRectangleAligned(rcLine, vsDraw.markers[markBit].BackWithAlpha());
- } else if (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) {
+ } else if (vsDraw.markers[markBit].markType == MarkerSymbol::Underline) {
PRectangle rcUnderline = rcLine;
rcUnderline.top = rcUnderline.bottom - 2;
surface->FillRectangleAligned(rcUnderline, vsDraw.markers[markBit].BackWithAlpha());
@@ -1917,7 +1920,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// Foreground drawing loop
BreakFinder bfFore(ll, &model.sel, lineRange, posLineStart, xStartVisible,
- (((phasesDraw == PhasesDraw::one) && selBackDrawn) || vsDraw.SelectionTextDrawn()), model.pdoc, &model.reprs, &vsDraw);
+ (((phasesDraw == PhasesDraw::One) && selBackDrawn) || vsDraw.SelectionTextDrawn()), model.pdoc, &model.reprs, &vsDraw);
while (bfFore.More()) {
@@ -1937,8 +1940,8 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// Hot-spot foreground
const bool inHotspot = (ll->hotspot.Valid()) && ll->hotspot.ContainsCharacter(iDoc);
if (inHotspot) {
- if (vsDraw.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE))
- textFore = *vsDraw.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE);
+ if (vsDraw.ElementColour(Element::HotSpotActive))
+ textFore = *vsDraw.ElementColour(Element::HotSpotActive);
}
if (vsDraw.indicatorsSetFore) {
// At least one indicator sets the text colour so see if it applies to this segment
@@ -1953,13 +1956,13 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
hover = rangeRun.ContainsCharacter(model.hoverIndicatorPos);
}
if (hover) {
- if (indicator.sacHover.style == INDIC_TEXTFORE) {
+ if (indicator.sacHover.style == IndicatorStyle::TextFore) {
textFore = indicator.sacHover.fore;
}
} else {
- if (indicator.sacNormal.style == INDIC_TEXTFORE) {
- if (indicator.Flags() & SC_INDICFLAG_VALUEFORE)
- textFore = ColourRGBA::FromRGB(indicatorValue & SC_INDICVALUEMASK);
+ if (indicator.sacNormal.style == IndicatorStyle::TextFore) {
+ if (FlagSet(indicator.Flags(), IndicFlag::ValueFore))
+ textFore = ColourRGBA::FromRGB(indicatorValue & static_cast<int>(IndicValue::Mask));
else
textFore = indicator.sacNormal.fore;
}
@@ -1976,12 +1979,12 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (ts.representation) {
if (ll->chars[i] == '\t') {
// Tab display
- if (phasesDraw == PhasesDraw::one) {
+ if (phasesDraw == PhasesDraw::One) {
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation))
- textBack = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque();
+ textBack = vsDraw.ElementColour(Element::WhiteSpaceBack)->Opaque();
surface->FillRectangleAligned(rcSegment, Fill(textBack));
}
- if (inIndentation && vsDraw.viewIndentationGuides == IndentView::real) {
+ if (inIndentation && vsDraw.viewIndentationGuides == IndentView::Real) {
for (int indentCount = static_cast<int>((ll->positions[i] + epsilon) / indentWidth);
indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth;
indentCount++) {
@@ -1992,12 +1995,12 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
}
}
}
- if (vsDraw.viewWhitespace != WhiteSpace::invisible) {
+ if (vsDraw.viewWhitespace != WhiteSpace::Invisible) {
if (vsDraw.WhiteSpaceVisible(inIndentation)) {
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 ColourRGBA whiteSpaceFore = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE).value_or(textFore);
+ const ColourRGBA whiteSpaceFore = vsDraw.ElementColour(Element::WhiteSpace).value_or(textFore);
if (!customDrawTabArrow)
DrawTabArrow(surface, rcTab, segmentTop, vsDraw, Stroke(whiteSpaceFore, 1.0f));
else
@@ -2010,21 +2013,21 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
// Using one font for all control characters so it can be controlled independently to ensure
// the box goes around the characters tightly. Seems to be no way to work out what height
// is taken by an individual character - internal leading gives varying results.
- const Font *ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font.get();
+ const Font *ctrlCharsFont = vsDraw.styles[StyleControlChar].font.get();
const char cc[2] = { static_cast<char>(vsDraw.controlCharSymbol), '\0' };
surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
rcSegment.top + vsDraw.maxAscent,
cc, textBack, textFore);
} else {
DrawTextBlob(surface, vsDraw, rcSegment, ts.representation->stringRep,
- textBack, textFore, phasesDraw == PhasesDraw::one);
+ textBack, textFore, phasesDraw == PhasesDraw::One);
}
}
} else {
// Normal text display
if (vsDraw.styles[styleMain].visible) {
const std::string_view text(&ll->chars[ts.start], i - ts.start + 1);
- if (phasesDraw != PhasesDraw::one) {
+ if (phasesDraw != PhasesDraw::One) {
surface->DrawTextTransparent(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, text, textFore);
} else {
@@ -2032,15 +2035,15 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
rcSegment.top + vsDraw.maxAscent, text, textFore, textBack);
}
}
- if (vsDraw.viewWhitespace != WhiteSpace::invisible ||
- (inIndentation && vsDraw.viewIndentationGuides != IndentView::none)) {
+ if (vsDraw.viewWhitespace != WhiteSpace::Invisible ||
+ (inIndentation && vsDraw.viewIndentationGuides != IndentView::None)) {
for (int cpos = 0; cpos <= i - ts.start; cpos++) {
if (ll->chars[cpos + ts.start] == ' ') {
- if (vsDraw.viewWhitespace != WhiteSpace::invisible) {
+ if (vsDraw.viewWhitespace != WhiteSpace::Invisible) {
if (vsDraw.WhiteSpaceVisible(inIndentation)) {
const XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
- if ((phasesDraw == PhasesDraw::one) && drawWhitespaceBackground) {
- textBack = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE_BACK)->Opaque();
+ if ((phasesDraw == PhasesDraw::One) && drawWhitespaceBackground) {
+ textBack = vsDraw.ElementColour(Element::WhiteSpaceBack)->Opaque();
const PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
@@ -2053,11 +2056,11 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f);
rcDot.right = rcDot.left + vsDraw.whitespaceSize;
rcDot.bottom = rcDot.top + vsDraw.whitespaceSize;
- const ColourRGBA whiteSpaceFore = vsDraw.ElementColour(SC_ELEMENT_WHITE_SPACE).value_or(textFore);
+ const ColourRGBA whiteSpaceFore = vsDraw.ElementColour(Element::WhiteSpace).value_or(textFore);
surface->FillRectangleAligned(rcDot, Fill(whiteSpaceFore));
}
}
- if (inIndentation && vsDraw.viewIndentationGuides == IndentView::real) {
+ if (inIndentation && vsDraw.viewIndentationGuides == IndentView::Real) {
for (int indentCount = static_cast<int>((ll->positions[cpos + ts.start] + epsilon) / indentWidth);
indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth;
indentCount++) {
@@ -2078,8 +2081,8 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
PRectangle rcUL = rcSegment;
rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
rcUL.bottom = rcUL.top + 1;
- if (vsDraw.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE))
- surface->FillRectangleAligned(rcUL, Fill(*vsDraw.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE)));
+ if (vsDraw.ElementColour(Element::HotSpotActive))
+ surface->FillRectangleAligned(rcUL, Fill(*vsDraw.ElementColour(Element::HotSpotActive)));
else
surface->FillRectangleAligned(rcUL, Fill(textFore));
} else if (vsDraw.styles[styleMain].underline) {
@@ -2096,7 +2099,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line line, Sci::Line lineVisible, PRectangle rcLine, int xStart, int subLine) {
- if ((vsDraw.viewIndentationGuides == IndentView::lookForward || vsDraw.viewIndentationGuides == IndentView::lookBoth)
+ if ((vsDraw.viewIndentationGuides == IndentView::LookForward || vsDraw.viewIndentationGuides == IndentView::LookBoth)
&& (subLine == 0)) {
const Sci::Position posLineStart = model.pdoc->LineStart(line);
int indentSpace = model.pdoc->GetLineIndentation(line);
@@ -2112,12 +2115,12 @@ void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &mode
xStartText = 100000; // Don't limit to visible indentation on empty line
// This line is empty, so use indentation of last line with text
int indentLastWithText = model.pdoc->GetLineIndentation(lineLastWithText);
- const int isFoldHeader = LevelIsHeader(model.pdoc->GetLevel(lineLastWithText));
+ const int isFoldHeader = LevelIsHeader(model.pdoc->GetFoldLevel(lineLastWithText));
if (isFoldHeader) {
// Level is one more level than parent
indentLastWithText += model.pdoc->IndentSize();
}
- if (vsDraw.viewIndentationGuides == IndentView::lookForward) {
+ if (vsDraw.viewIndentationGuides == IndentView::LookForward) {
// In viLookForward mode, previous line only used if it is a fold header
if (isFoldHeader) {
indentSpace = std::max(indentSpace, indentLastWithText);
@@ -2172,7 +2175,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
xStart += static_cast<int>(ll->wrapIndent);
}
- if (phasesDraw != PhasesDraw::one) {
+ if (phasesDraw != PhasesDraw::One) {
if (FlagSet(phase, DrawPhase::back)) {
DrawBackground(surface, model, vsDraw, ll, rcLine, lineRange, posLineStart, xStart,
subLine, background);
@@ -2195,8 +2198,8 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
}
if (FlagSet(phase, DrawPhase::text)) {
- DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::under);
- DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine, Layer::under);
+ DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::UnderText);
+ DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine, Layer::UnderText);
DrawForeground(surface, model, vsDraw, ll, lineVisible, rcLine, lineRange, posLineStart, xStart,
subLine, background);
}
@@ -2213,7 +2216,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
DrawFoldDisplayText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, phase);
DrawEOLAnnotationText(surface, model, vsDraw, ll, line, xStart, rcLine, subLine, subLineStart, phase);
- if (phasesDraw == PhasesDraw::one) {
+ if (phasesDraw == PhasesDraw::One) {
DrawEOL(surface, model, vsDraw, ll, rcLine, line, lineRange.end,
xStart, subLine, subLineStart, background);
if (vsDraw.IsLineFrameOpaque(model.caret.active, ll->containsCaret))
@@ -2223,35 +2226,35 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl
}
if (!hideSelection && FlagSet(phase, DrawPhase::selectionTranslucent)) {
- DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::over);
+ DrawTranslucentSelection(surface, model, vsDraw, ll, line, rcLine, subLine, lineRange, xStart, tabWidthMinimumPixels, Layer::OverText);
}
if (FlagSet(phase, DrawPhase::lineTranslucent)) {
- DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine, Layer::over);
+ DrawTranslucentLineState(surface, model, vsDraw, ll, line, rcLine, subLine, Layer::OverText);
}
}
static void DrawFoldLines(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, Sci::Line line, PRectangle rcLine) {
const bool expanded = model.pcs->GetExpanded(line);
- const int level = model.pdoc->GetLevel(line);
- const int levelNext = model.pdoc->GetLevel(line + 1);
+ const FoldLevel level = model.pdoc->GetFoldLevel(line);
+ const FoldLevel levelNext = model.pdoc->GetFoldLevel(line + 1);
if (LevelIsHeader(level) &&
(LevelNumber(level) < LevelNumber(levelNext))) {
// Paint the line above the fold
- if ((expanded && (model.foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED))
+ if ((expanded && (FlagSet(model.foldFlags, FoldFlag::LineBeforeExpanded)))
||
- (!expanded && (model.foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) {
+ (!expanded && (FlagSet(model.foldFlags, FoldFlag::LineBeforeContracted)))) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.bottom = rcFoldLine.top + 1;
- surface->FillRectangleAligned(rcFoldLine, Fill(vsDraw.styles[STYLE_DEFAULT].fore));
+ surface->FillRectangleAligned(rcFoldLine, Fill(vsDraw.styles[StyleDefault].fore));
}
// Paint the line below the fold
- if ((expanded && (model.foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED))
+ if ((expanded && (FlagSet(model.foldFlags, FoldFlag::LineAfterExpanded)))
||
- (!expanded && (model.foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) {
+ (!expanded && (FlagSet(model.foldFlags, FoldFlag::LineAfterContracted)))) {
PRectangle rcFoldLine = rcLine;
rcFoldLine.top = rcFoldLine.bottom - 1;
- surface->FillRectangleAligned(rcFoldLine, Fill(vsDraw.styles[STYLE_DEFAULT].fore));
+ surface->FillRectangleAligned(rcFoldLine, Fill(vsDraw.styles[StyleDefault].fore));
}
}
}
@@ -2306,13 +2309,13 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
double durCopy = 0.0;
ElapsedPeriod epWhole;
#endif
- const bool bracesIgnoreStyle = ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACELIGHT)) ||
- (vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == STYLE_BRACEBAD)));
+ const bool bracesIgnoreStyle = ((vsDraw.braceHighlightIndicatorSet && (model.bracesMatchStyle == StyleBraceLight)) ||
+ (vsDraw.braceBadLightIndicatorSet && (model.bracesMatchStyle == StyleBraceBad)));
Sci::Line lineDocPrevious = -1; // Used to avoid laying out one document line multiple times
std::shared_ptr<LineLayout> ll;
std::vector<DrawPhase> phases;
- if ((phasesDraw == PhasesDraw::multiple) && !bufferedDraw) {
+ if ((phasesDraw == PhasesDraw::Multiple) && !bufferedDraw) {
for (DrawPhase phase = DrawPhase::back; phase <= DrawPhase::carets; phase = static_cast<DrawPhase>(static_cast<int>(phase) * 2)) {
phases.push_back(phase);
}
@@ -2361,12 +2364,12 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
ll->SetBracesHighlight(rangeLine, model.braces, static_cast<char>(model.bracesMatchStyle),
static_cast<int>(model.highlightGuideColumn * vsDraw.spaceWidth), bracesIgnoreStyle);
- if (leftTextOverlap && (bufferedDraw || ((phasesDraw < PhasesDraw::multiple) && (FlagSet(phase, DrawPhase::back))))) {
+ if (leftTextOverlap && (bufferedDraw || ((phasesDraw < PhasesDraw::Multiple) && (FlagSet(phase, DrawPhase::back))))) {
// Clear the left margin
PRectangle rcSpacer = rcLine;
rcSpacer.right = rcSpacer.left;
rcSpacer.left -= 1;
- surface->FillRectangleAligned(rcSpacer, Fill(vsDraw.styles[STYLE_DEFAULT].back));
+ surface->FillRectangleAligned(rcSpacer, Fill(vsDraw.styles[StyleDefault].back));
}
if (model.BidirectionalEnabled()) {
@@ -2424,13 +2427,13 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
rcBeyondEOF.right = rcBeyondEOF.right - ((vsDraw.marginInside) ? vsDraw.rightMarginWidth : 0);
rcBeyondEOF.top = static_cast<XYPOSITION>((model.pcs->LinesDisplayed() - model.TopLineOfMain()) * vsDraw.lineHeight);
if (rcBeyondEOF.top < rcBeyondEOF.bottom) {
- surfaceWindow->FillRectangleAligned(rcBeyondEOF, Fill(vsDraw.styles[STYLE_DEFAULT].back));
- if (vsDraw.edgeState == EDGE_LINE) {
+ surfaceWindow->FillRectangleAligned(rcBeyondEOF, Fill(vsDraw.styles[StyleDefault].back));
+ if (vsDraw.edgeState == EdgeVisualStyle::Line) {
const int edgeX = static_cast<int>(vsDraw.theEdge.column * vsDraw.spaceWidth);
rcBeyondEOF.left = static_cast<XYPOSITION>(edgeX + xStart);
rcBeyondEOF.right = rcBeyondEOF.left + 1;
surfaceWindow->FillRectangleAligned(rcBeyondEOF, Fill(vsDraw.theEdge.colour));
- } else if (vsDraw.edgeState == EDGE_MULTILINE) {
+ } else if (vsDraw.edgeState == EdgeVisualStyle::MultiLine) {
for (size_t edge = 0; edge < vsDraw.theMultiEdge.size(); edge++) {
if (vsDraw.theMultiEdge[edge].column >= 0) {
const int edgeX = static_cast<int>(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth);
@@ -2463,7 +2466,7 @@ void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const
const std::optional<ColourRGBA> background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
- if (eolInSelection && vsDraw.selection.eolFilled && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::base)) {
+ if (eolInSelection && vsDraw.selection.eolFilled && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer == Layer::Base)) {
surface->FillRectangleAligned(rcArea, Fill(SelectionBackground(model, vsDraw, eolInSelection).Opaque()));
} else {
if (background) {
@@ -2471,9 +2474,9 @@ void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const
} else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) {
surface->FillRectangleAligned(rcArea, Fill(vsDraw.styles[ll->styles[ll->numCharsInLine]].back));
} else {
- surface->FillRectangleAligned(rcArea, Fill(vsDraw.styles[STYLE_DEFAULT].back));
+ surface->FillRectangleAligned(rcArea, Fill(vsDraw.styles[StyleDefault].back));
}
- if (eolInSelection && vsDraw.selection.eolFilled && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::base)) {
+ if (eolInSelection && vsDraw.selection.eolFilled && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::Base)) {
surface->FillRectangleAligned(rcArea, SelectionBackground(model, vsDraw, eolInSelection));
}
}
@@ -2496,19 +2499,19 @@ static ColourRGBA InvertedLight(ColourRGBA orig) noexcept {
return ColourRGBA(std::min(r, 0xffu), std::min(g, 0xffu), std::min(b, 0xffu));
}
-Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure,
+Sci::Position EditView::FormatRange(bool draw, const RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure,
const EditModel &model, const ViewStyle &vs) {
// Can't use measurements cached for screen
posCache.Clear();
ViewStyle vsPrint(vs);
- vsPrint.technology = SC_TECHNOLOGY_DEFAULT;
+ vsPrint.technology = Technology::Default;
// Modify the view style for printing as do not normally want any of the transient features to be printed
// Printing supports only the line number margin.
int lineNumberIndex = -1;
for (size_t margin = 0; margin < vs.ms.size(); margin++) {
- if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) {
+ if ((vsPrint.ms[margin].style == MarginType::Number) && (vsPrint.ms[margin].width > 0)) {
lineNumberIndex = static_cast<int>(margin);
} else {
vsPrint.ms[margin].width = 0;
@@ -2517,8 +2520,8 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur
vsPrint.fixedColumnWidth = 0;
vsPrint.zoomLevel = printParameters.magnification;
// Don't show indentation guides
- // If this ever gets changed, cached pixmap would need to be recreated if technology != SC_TECHNOLOGY_DEFAULT
- vsPrint.viewIndentationGuides = IndentView::none;
+ // If this ever gets changed, cached pixmap would need to be recreated if technology != Technology::Default
+ vsPrint.viewIndentationGuides = IndentView::None;
// Don't show the selection when printing
vsPrint.elementColours.clear();
vsPrint.elementBaseColours.clear();
@@ -2529,23 +2532,23 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur
// Set colours for printing according to users settings
for (size_t sty = 0; sty < vsPrint.styles.size(); sty++) {
- if (printParameters.colourMode == SC_PRINT_INVERTLIGHT) {
+ if (printParameters.colourMode == PrintOption::InvertLight) {
vsPrint.styles[sty].fore = InvertedLight(vsPrint.styles[sty].fore);
vsPrint.styles[sty].back = InvertedLight(vsPrint.styles[sty].back);
- } else if (printParameters.colourMode == SC_PRINT_BLACKONWHITE) {
+ } else if (printParameters.colourMode == PrintOption::BlackOnWhite) {
vsPrint.styles[sty].fore = ColourRGBA(0, 0, 0);
vsPrint.styles[sty].back = ColourRGBA(0xff, 0xff, 0xff);
- } else if (printParameters.colourMode == SC_PRINT_COLOURONWHITE) {
+ } else if (printParameters.colourMode == PrintOption::ColourOnWhite) {
vsPrint.styles[sty].back = ColourRGBA(0xff, 0xff, 0xff);
- } else if (printParameters.colourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
- if (sty <= STYLE_DEFAULT) {
+ } else if (printParameters.colourMode == PrintOption::ColourOnWhiteDefaultBG) {
+ if (sty <= StyleDefault) {
vsPrint.styles[sty].back = ColourRGBA(0xff, 0xff, 0xff);
}
}
}
- // White background for the line numbers if SC_PRINT_SCREENCOLOURS isn't used
- if (printParameters.colourMode != SC_PRINT_SCREENCOLOURS)
- vsPrint.styles[STYLE_LINENUMBER].back = ColourRGBA(0xff, 0xff, 0xff);
+ // White background for the line numbers if PrintOption::ScreenColours isn't used
+ if (printParameters.colourMode != PrintOption::ScreenColours)
+ vsPrint.styles[StyleLineNumber].back = ColourRGBA(0xff, 0xff, 0xff);
// Printing uses different margins, so reset screen margins
vsPrint.leftMarginWidth = 0;
@@ -2555,7 +2558,7 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur
// Determining width must happen after fonts have been realised in Refresh
int lineNumberWidth = 0;
if (lineNumberIndex >= 0) {
- lineNumberWidth = static_cast<int>(surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font.get(),
+ lineNumberWidth = static_cast<int>(surfaceMeasure->WidthText(vsPrint.styles[StyleLineNumber].font.get(),
"99999" lineNumberPrintSpace));
vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
vsPrint.Refresh(*surfaceMeasure, model.pdoc->tabInChars); // Recalculate fixedColumnWidth
@@ -2570,7 +2573,7 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur
linePrintLast = linePrintMax;
//Platform::DebugPrintf("Formatting lines=[%0d,%0d,%0d] top=%0d bottom=%0d line=%0d %0d\n",
// linePrintStart, linePrintLast, linePrintMax, pfr->rc.top, pfr->rc.bottom, vsPrint.lineHeight,
- // surfaceMeasure->Height(vsPrint.styles[STYLE_LINENUMBER].font));
+ // surfaceMeasure->Height(vsPrint.styles[StyleLineNumber].font));
Sci::Position endPosPrint = model.pdoc->Length();
if (linePrintLast < model.pdoc->LinesTotal())
endPosPrint = model.pdoc->LineStart(linePrintLast + 1);
@@ -2586,7 +2589,7 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur
Sci::Position nPrintPos = pfr->chrg.cpMin;
int visibleLine = 0;
int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth;
- if (printParameters.wrapState == WrapMode::none)
+ if (printParameters.wrapState == Wrap::None)
widthPrint = LineLayout::wrapWidthInfinite;
while (lineDoc <= linePrintLast && ypos < pfr->rc.bottom) {
@@ -2635,12 +2638,12 @@ Sci::Position EditView::FormatRange(bool draw, const Sci_RangeToFormat *pfr, Sur
rcNumber.right = rcNumber.left + lineNumberWidth;
// Right justify
rcNumber.left = rcNumber.right - surfaceMeasure->WidthText(
- vsPrint.styles[STYLE_LINENUMBER].font.get(), number);
+ vsPrint.styles[StyleLineNumber].font.get(), number);
surface->FlushCachedState();
- surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font.get(),
+ surface->DrawTextNoClip(rcNumber, vsPrint.styles[StyleLineNumber].font.get(),
static_cast<XYPOSITION>(ypos + vsPrint.maxAscent), number,
- vsPrint.styles[STYLE_LINENUMBER].fore,
- vsPrint.styles[STYLE_LINENUMBER].back);
+ vsPrint.styles[StyleLineNumber].fore,
+ vsPrint.styles[StyleLineNumber].back);
}
// Draw the line
diff --git a/src/EditView.h b/src/EditView.h
index f936a8a56..148d6e52d 100644
--- a/src/EditView.h
+++ b/src/EditView.h
@@ -8,12 +8,12 @@
#ifndef EDITVIEW_H
#define EDITVIEW_H
-namespace Scintilla {
+namespace Scintilla::Internal {
struct PrintParameters {
int magnification;
- int colourMode;
- WrapMode wrapState;
+ Scintilla::PrintOption colourMode;
+ Scintilla::Wrap wrapState;
PrintParameters() noexcept;
};
@@ -66,8 +66,7 @@ public:
* In multiPhaseDraw mode, drawing is performed in multiple phases with each phase drawing
* one feature over the whole drawing area, instead of within one line. This allows text to
* overlap from one line to the next. */
- enum class PhasesDraw { one, two, multiple };
- PhasesDraw phasesDraw;
+ Scintilla::PhasesDraw phasesDraw;
int lineWidthMaxSeen;
@@ -154,7 +153,7 @@ public:
const ViewStyle &vsDraw);
void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
Sci::Line line, PRectangle rcArea, int subLine) const;
- Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure,
+ Sci::Position FormatRange(bool draw, const Scintilla::RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure,
const EditModel &model, const ViewStyle &vs);
};
diff --git a/src/Editor.cxx b/src/Editor.cxx
index fbda7a44e..29f79e16c 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -25,14 +25,16 @@
#include <memory>
#include <chrono>
+#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 "CharacterType.h"
#include "CharacterCategoryMap.h"
#include "Position.h"
@@ -62,6 +64,7 @@
#include "ElapsedPeriod.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
namespace {
@@ -70,18 +73,18 @@ namespace {
may reasonably be deferred (not done now OR [possibly] at all)
*/
constexpr bool CanDeferToLastStep(const DocModification &mh) noexcept {
- if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE))
+ if (FlagSet(mh.modificationType, (ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete)))
return true; // CAN skip
- if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)))
+ if (!FlagSet(mh.modificationType, (ModificationFlags::Undo | ModificationFlags::Redo)))
return false; // MUST do
- if (mh.modificationType & SC_MULTISTEPUNDOREDO)
+ if (FlagSet(mh.modificationType, ModificationFlags::MultiStepUndoRedo))
return true; // CAN skip
return false; // PRESUMABLY must do
}
constexpr bool CanEliminate(const DocModification &mh) noexcept {
return
- (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0;
+ FlagSet(mh.modificationType, (ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete));
}
/*
@@ -90,10 +93,10 @@ constexpr bool CanEliminate(const DocModification &mh) noexcept {
*/
constexpr bool IsLastStep(const DocModification &mh) noexcept {
return
- (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0
- && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0
- && (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0
- && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0;
+ FlagSet(mh.modificationType, (ModificationFlags::Undo | ModificationFlags::Redo))
+ && (FlagSet(mh.modificationType, ModificationFlags::MultiStepUndoRedo))
+ && (FlagSet(mh.modificationType, ModificationFlags::LastStepInUndoRedo))
+ && (FlagSet(mh.modificationType, ModificationFlags::MultilineUndoRedo));
}
}
@@ -117,19 +120,19 @@ Editor::Editor() : durationWrapOneByte(0.000001, 0.0000001, 0.00001) {
ctrlID = 0;
stylesValid = false;
- technology = SC_TECHNOLOGY_DEFAULT;
+ technology = Technology::Default;
scaleRGBAImage = 100.0f;
- cursorMode = SC_CURSORNORMAL;
+ cursorMode = CursorShape::Normal;
- errorStatus = 0;
+ errorStatus = Status::Ok;
mouseDownCaptures = true;
mouseWheelCaptures = true;
lastClickTime = 0;
doubleClickCloseThreshold = Point(3, 3);
- dwellDelay = SC_TIME_FOREVER;
- ticksToDwell = SC_TIME_FOREVER;
+ dwellDelay = TimeForever;
+ ticksToDwell = TimeForever;
dwelling = false;
ptMouseLast.x = 0;
ptMouseLast.y = 0;
@@ -146,8 +149,8 @@ Editor::Editor() : durationWrapOneByte(0.000001, 0.0000001, 0.00001) {
wordSelectAnchorEndPos = 0;
wordSelectInitialCaretPos = -1;
- caretPolicies.x = { CARET_SLOP | CARET_EVEN, 50 };
- caretPolicies.y = { CARET_EVEN, 0 };
+ caretPolicies.x = { CaretPolicy::Slop | CaretPolicy::Even, 50 };
+ caretPolicies.y = { CaretPolicy::Even, 0 };
visiblePolicy = { 0, 0 };
@@ -158,39 +161,39 @@ Editor::Editor() : durationWrapOneByte(0.000001, 0.0000001, 0.00001) {
scrollWidth = 2000;
verticalScrollBarVisible = true;
endAtLastLine = true;
- caretSticky = SC_CARETSTICKY_OFF;
- marginOptions = SC_MARGINOPTION_NONE;
+ caretSticky = CaretSticky::Off;
+ marginOptions = MarginOption::None;
mouseSelectionRectangularSwitch = false;
multipleSelection = false;
additionalSelectionTyping = false;
- multiPasteMode = SC_MULTIPASTE_ONCE;
- virtualSpaceOptions = SCVS_NONE;
+ multiPasteMode = MultiPaste::Once;
+ virtualSpaceOptions = VirtualSpace::None;
targetRange = SelectionSegment();
- searchFlags = 0;
+ searchFlags = FindOption::None;
topLine = 0;
posTopLine = 0;
lengthForEncode = -1;
- needUpdateUI = 0;
- ContainerNeedsUpdate(SC_UPDATE_CONTENT);
+ needUpdateUI = Update::None;
+ ContainerNeedsUpdate(Update::Content);
paintState = PaintState::notPainting;
paintAbandonedByStyling = false;
paintingAllText = false;
willRedrawAll = false;
- idleStyling = SC_IDLESTYLING_NONE;
+ idleStyling = IdleStyling::None;
needIdleStyling = false;
- modEventMask = SC_MODEVENTMASKALL;
+ modEventMask = ModificationFlags::EventMaskAll;
commandEvents = true;
pdoc->AddWatcher(this, nullptr);
recordingMacro = false;
- foldAutomatic = 0;
+ foldAutomatic = AutomaticFold::None;
convertPastes = true;
@@ -443,7 +446,7 @@ Sci::Line Editor::LineFromLocation(Point pt) const {
void Editor::SetTopLine(Sci::Line topLineNew) {
if ((topLine != topLineNew) && (topLineNew >= 0)) {
topLine = topLineNew;
- ContainerNeedsUpdate(SC_UPDATE_V_SCROLL);
+ ContainerNeedsUpdate(Update::VScroll);
}
posTopLine = pdoc->LineStart(pcs->DocFromDisplay(topLine));
}
@@ -592,7 +595,7 @@ void Editor::SetRectangularRange() {
SelectionRange range(
view.SPositionFromLineX(surface, *this, line, xCaret, vs),
view.SPositionFromLineX(surface, *this, line, xAnchor, vs));
- if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0)
+ if ((FlagSet(virtualSpaceOptions, VirtualSpace::RectangularSelection)) == 0)
range.ClearVirtualSpace();
if (line == lineAnchorRect)
sel.SetSelection(range);
@@ -630,7 +633,7 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel
lastAffected = std::max(lastAffected, sel.Range(r).anchor.Position());
}
}
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
InvalidateRange(firstAffected, lastAffected);
}
@@ -769,7 +772,7 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) {
selectedText.c_str(), searchFlags, &lengthFound);
if (pos >= 0) {
sel.AddSelection(SelectionRange(pos + lengthFound, pos));
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
ScrollRange(sel.RangeMain());
Redraw();
if (addNumber == AddNumber::one)
@@ -984,7 +987,7 @@ void Editor::HorizontalScrollTo(int xPos) {
xPos = 0;
if (!Wrapping() && (xOffset != xPos)) {
xOffset = xPos;
- ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
+ ContainerNeedsUpdate(Update::HScroll);
SetHorizontalScrollPos();
RedrawRect(GetClientRectangle());
}
@@ -1157,14 +1160,14 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
// Vertical positioning
if (FlagSet(options, XYScrollOptions::vertical) &&
- (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || (policies.y.policy & CARET_STRICT) != 0)) {
+ (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || (FlagSet(policies.y.policy, CaretPolicy::Strict)) != 0)) {
const Sci::Line lineCaret = DisplayFromPosition(range.caret.Position());
const Sci::Line linesOnScreen = LinesOnScreen();
const Sci::Line halfScreen = std::max(linesOnScreen - 1, static_cast<Sci::Line>(2)) / 2;
- const bool bSlop = (policies.y.policy & CARET_SLOP) != 0;
- const bool bStrict = (policies.y.policy & CARET_STRICT) != 0;
- const bool bJump = (policies.y.policy & CARET_JUMPS) != 0;
- const bool bEven = (policies.y.policy & CARET_EVEN) != 0;
+ const bool bSlop = (FlagSet(policies.y.policy, CaretPolicy::Slop)) != 0;
+ const bool bStrict = (FlagSet(policies.y.policy, CaretPolicy::Strict)) != 0;
+ const bool bJump = (FlagSet(policies.y.policy, CaretPolicy::Jumps)) != 0;
+ const bool bEven = (FlagSet(policies.y.policy, CaretPolicy::Even)) != 0;
// It should be possible to scroll the window to show the caret,
// but this fails to remove the caret on GTK+
@@ -1260,10 +1263,10 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
// Horizontal positioning
if (FlagSet(options, XYScrollOptions::horizontal) && !Wrapping()) {
const int halfScreen = std::max(static_cast<int>(rcClient.Width()) - 4, 4) / 2;
- const bool bSlop = (policies.x.policy & CARET_SLOP) != 0;
- const bool bStrict = (policies.x.policy & CARET_STRICT) != 0;
- const bool bJump = (policies.x.policy & CARET_JUMPS) != 0;
- const bool bEven = (policies.x.policy & CARET_EVEN) != 0;
+ const bool bSlop = (FlagSet(policies.x.policy, CaretPolicy::Slop)) != 0;
+ const bool bStrict = (FlagSet(policies.x.policy, CaretPolicy::Strict)) != 0;
+ const bool bJump = (FlagSet(policies.x.policy, CaretPolicy::Jumps)) != 0;
+ const bool bEven = (FlagSet(policies.x.policy, CaretPolicy::Even)) != 0;
if (bSlop) { // A margin is defined
int xMoveL, xMoveR;
@@ -1389,7 +1392,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) {
}
if (newXY.xOffset != xOffset) {
xOffset = newXY.xOffset;
- ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
+ ContainerNeedsUpdate(Update::HScroll);
if (newXY.xOffset > 0) {
const PRectangle rcText = GetTextRectangle();
if (horizontalScrollBarVisible &&
@@ -1409,14 +1412,6 @@ void Editor::ScrollRange(SelectionRange range) {
SetXYScroll(XYScrollToMakeVisible(range, XYScrollOptions::all, caretPolicies));
}
-namespace {
-
-constexpr XYScrollOptions operator|(XYScrollOptions a, XYScrollOptions b) noexcept {
- return static_cast<XYScrollOptions>(static_cast<int>(a) | static_cast<int>(b));
-}
-
-}
-
void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
SetXYScroll(XYScrollToMakeVisible(SelectionRange(posDrag.IsValid() ? posDrag : sel.RangeMain().caret),
(useMargin?XYScrollOptions::useMargin:XYScrollOptions::none)|
@@ -1475,7 +1470,7 @@ void Editor::UpdateSystemCaret() {
}
bool Editor::Wrapping() const noexcept {
- return vs.wrap.state != WrapMode::none;
+ return vs.wrap.state != Wrap::None;
}
void Editor::NeedWrapping(Sci::Line docLineStart, Sci::Line docLineEnd) {
@@ -1497,7 +1492,7 @@ bool Editor::WrapOneLine(Surface *surface, Sci::Line lineToWrap) {
linesWrapped = ll->lines;
}
return pcs->SetHeight(lineToWrap, linesWrapped +
- (vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0));
+ ((vs.annotationVisible != AnnotationVisible::Hidden) ? pdoc->AnnotationLines(lineToWrap) : 0));
}
// Perform wrapping for a subset of the lines needing wrapping.
@@ -1513,7 +1508,7 @@ bool Editor::WrapLines(WrapScope ws) {
wrapWidth = LineLayout::wrapWidthInfinite;
for (Sci::Line lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) {
pcs->SetHeight(lineDoc, 1 +
- (vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0));
+ ((vs.annotationVisible != AnnotationVisible::Hidden) ? pdoc->AnnotationLines(lineDoc) : 0));
}
wrapOccurred = true;
}
@@ -1629,10 +1624,10 @@ void Editor::LinesJoin() {
}
}
-const char *Editor::StringFromEOLMode(int eolMode) noexcept {
- if (eolMode == SC_EOL_CRLF) {
+const char *Editor::StringFromEOLMode(EndOfLine eolMode) noexcept {
+ if (eolMode == EndOfLine::CrLf) {
return "\r\n";
- } else if (eolMode == SC_EOL_CR) {
+ } else if (eolMode == EndOfLine::Cr) {
return "\r";
} else {
return "\n";
@@ -1776,14 +1771,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
PRectangle rcRightMargin = rcClient;
rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
if (rcArea.Intersects(rcRightMargin)) {
- surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back);
+ surfaceWindow->FillRectangle(rcRightMargin, vs.styles[StyleDefault].back);
}
} else { // Else separate view so separate paint event but leftMargin included to allow overlap
PRectangle rcLeftMargin = rcArea;
rcLeftMargin.left = 0;
rcLeftMargin.right = rcLeftMargin.left + vs.leftMarginWidth;
if (rcArea.Intersects(rcLeftMargin)) {
- surfaceWindow->FillRectangle(rcLeftMargin, vs.styles[STYLE_DEFAULT].back);
+ surfaceWindow->FillRectangle(rcLeftMargin, vs.styles[StyleDefault].back);
}
}
}
@@ -1822,14 +1817,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
// This is mostly copied from the Paint method but with some things omitted
// such as the margin markers, line numbers, selection and caret
// Should be merged back into a combined Draw method.
-Sci::Position Editor::FormatRange(bool draw, const Sci_RangeToFormat *pfr) {
+Sci::Position Editor::FormatRange(bool draw, const RangeToFormat *pfr) {
if (!pfr)
return 0;
- AutoSurface surface(pfr->hdc, this, SC_TECHNOLOGY_DEFAULT);
+ AutoSurface surface(pfr->hdc, this, Technology::Default);
if (!surface)
return 0;
- AutoSurface surfaceMeasure(pfr->hdcTarget, this, SC_TECHNOLOGY_DEFAULT);
+ AutoSurface surfaceMeasure(pfr->hdcTarget, this, Technology::Default);
if (!surfaceMeasure) {
return 0;
}
@@ -1911,7 +1906,7 @@ void Editor::AddChar(char ch) {
char s[2];
s[0] = ch;
s[1] = '\0';
- InsertCharacter(std::string_view(s, 1), CharacterSource::directInput);
+ InsertCharacter(std::string_view(s, 1), CharacterSource::DirectInput);
}
void Editor::FilterSelections() {
@@ -1991,13 +1986,13 @@ void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) {
EnsureCaretVisible();
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
- if ((caretSticky == SC_CARETSTICKY_OFF) ||
- ((caretSticky == SC_CARETSTICKY_WHITESPACE) && !IsAllSpacesOrTabs(sv))) {
+ if ((caretSticky == CaretSticky::Off) ||
+ ((caretSticky == CaretSticky::WhiteSpace) && !IsAllSpacesOrTabs(sv))) {
SetLastXChosen();
}
int ch = static_cast<unsigned char>(sv[0]);
- if (pdoc->dbcsCodePage != SC_CP_UTF8) {
+ if (pdoc->dbcsCodePage != CpUtf8) {
if (sv.length() > 1) {
// DBCS code page or DBCS font character set.
ch = (ch << 8) | static_cast<unsigned char>(sv[1]);
@@ -2016,9 +2011,9 @@ void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) {
}
NotifyChar(ch, charSource);
- if (recordingMacro && charSource != CharacterSource::tentativeInput) {
+ if (recordingMacro && charSource != CharacterSource::TentativeInput) {
std::string copy(sv); // ensure NUL-terminated
- NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(copy.data()));
+ NotifyMacroRecord(Message::ReplaceSel, 0, reinterpret_cast<sptr_t>(copy.data()));
}
}
@@ -2046,7 +2041,7 @@ void Editor::ClearBeforeTentativeStart() {
}
void Editor::InsertPaste(const char *text, Sci::Position len) {
- if (multiPasteMode == SC_MULTIPASTE_ONCE) {
+ if (multiPasteMode == MultiPaste::Once) {
SelectionPosition selStart = sel.Start();
selStart = RealizeVirtualSpace(selStart);
const Sci::Position lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
@@ -2054,7 +2049,7 @@ void Editor::InsertPaste(const char *text, Sci::Position len) {
SetEmptySelection(selStart.Position() + lengthInserted);
}
} else {
- // SC_MULTIPASTE_EACH
+ // MultiPaste::Each
for (size_t r=0; r<sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
@@ -2193,9 +2188,9 @@ void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Posit
if ((ptr[i] == '\r') || (!prevCr))
line++;
if (line >= pdoc->LinesTotal()) {
- if (pdoc->eolMode != SC_EOL_LF)
+ if (pdoc->eolMode != EndOfLine::Lf)
pdoc->InsertString(pdoc->Length(), "\r", 1);
- if (pdoc->eolMode != SC_EOL_CR)
+ if (pdoc->eolMode != EndOfLine::Cr)
pdoc->InsertString(pdoc->Length(), "\n", 1);
}
// Pad the end of lines with spaces if required
@@ -2321,23 +2316,23 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {
ClearSelection();
}
sel.RemoveDuplicates();
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
}
-int Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta, bool super) noexcept {
+KeyMod Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta, bool super) noexcept {
return
- (shift ? SCI_SHIFT : 0) |
- (ctrl ? SCI_CTRL : 0) |
- (alt ? SCI_ALT : 0) |
- (meta ? SCI_META : 0) |
- (super ? SCI_SUPER : 0);
+ (shift ? KeyMod::Shift : KeyMod::Norm) |
+ (ctrl ? KeyMod::Ctrl : KeyMod::Norm) |
+ (alt ? KeyMod::Alt : KeyMod::Norm) |
+ (meta ? KeyMod::Meta : KeyMod::Norm) |
+ (super ? KeyMod::Super : KeyMod::Norm);
}
void Editor::NotifyFocus(bool focus) {
- SCNotification scn = {};
- scn.nmhdr.code = focus ? SCN_FOCUSIN : SCN_FOCUSOUT;
+ NotificationData scn = {};
+ scn.nmhdr.code = focus ? Notification::FocusIn : Notification::FocusOut;
NotifyParent(scn);
}
@@ -2346,8 +2341,8 @@ void Editor::SetCtrlID(int identifier) {
}
void Editor::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_STYLENEEDED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::StyleNeeded;
scn.position = endStyleNeeded;
NotifyParent(scn);
}
@@ -2359,125 +2354,125 @@ void Editor::NotifyStyleNeeded(Document *, void *, Sci::Position endStyleNeeded)
void Editor::NotifyLexerChanged(Document *, void *) {
}
-void Editor::NotifyErrorOccurred(Document *, void *, int status) {
+void Editor::NotifyErrorOccurred(Document *, void *, Status status) {
errorStatus = status;
}
void Editor::NotifyChar(int ch, CharacterSource charSource) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_CHARADDED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::CharAdded;
scn.ch = ch;
- scn.characterSource = static_cast<int>(charSource);
+ scn.characterSource = charSource;
NotifyParent(scn);
}
void Editor::NotifySavePoint(bool isSavePoint) {
- SCNotification scn = {};
+ NotificationData scn = {};
if (isSavePoint) {
- scn.nmhdr.code = SCN_SAVEPOINTREACHED;
+ scn.nmhdr.code = Notification::SavePointReached;
} else {
- scn.nmhdr.code = SCN_SAVEPOINTLEFT;
+ scn.nmhdr.code = Notification::SavePointLeft;
}
NotifyParent(scn);
}
void Editor::NotifyModifyAttempt() {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_MODIFYATTEMPTRO;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::ModifyAttemptRO;
NotifyParent(scn);
}
-void Editor::NotifyDoubleClick(Point pt, int modifiers) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_DOUBLECLICK;
+void Editor::NotifyDoubleClick(Point pt, KeyMod modifiers) {
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::DoubleClick;
scn.line = LineFromLocation(pt);
scn.position = PositionFromLocation(pt, true);
scn.modifiers = modifiers;
NotifyParent(scn);
}
-void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK;
+void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, KeyMod modifiers) {
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::HotSpotDoubleClick;
scn.position = position;
scn.modifiers = modifiers;
NotifyParent(scn);
}
-void Editor::NotifyHotSpotClicked(Sci::Position position, int modifiers) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_HOTSPOTCLICK;
+void Editor::NotifyHotSpotClicked(Sci::Position position, KeyMod modifiers) {
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::HotSpotClick;
scn.position = position;
scn.modifiers = modifiers;
NotifyParent(scn);
}
-void Editor::NotifyHotSpotReleaseClick(Sci::Position position, int modifiers) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK;
+void Editor::NotifyHotSpotReleaseClick(Sci::Position position, KeyMod modifiers) {
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::HotSpotReleaseClick;
scn.position = position;
scn.modifiers = modifiers;
NotifyParent(scn);
}
bool Editor::NotifyUpdateUI() {
- if (needUpdateUI) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_UPDATEUI;
+ if (needUpdateUI != Update::None) {
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::UpdateUI;
scn.updated = needUpdateUI;
NotifyParent(scn);
- needUpdateUI = 0;
+ needUpdateUI = Update::None;
return true;
}
return false;
}
void Editor::NotifyPainted() {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_PAINTED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::Painted;
NotifyParent(scn);
}
-void Editor::NotifyIndicatorClick(bool click, Sci::Position position, int modifiers) {
+void Editor::NotifyIndicatorClick(bool click, Sci::Position position, KeyMod modifiers) {
const int mask = pdoc->decorations->AllOnFor(position);
if ((click && mask) || pdoc->decorations->ClickNotified()) {
- SCNotification scn = {};
+ NotificationData scn = {};
pdoc->decorations->SetClickNotified(click);
- scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE;
+ scn.nmhdr.code = click ? Notification::IndicatorClick : Notification::IndicatorRelease;
scn.modifiers = modifiers;
scn.position = position;
NotifyParent(scn);
}
}
-bool Editor::NotifyMarginClick(Point pt, int modifiers) {
+bool Editor::NotifyMarginClick(Point pt, KeyMod modifiers) {
const int marginClicked = vs.MarginFromLocation(pt);
if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) {
const Sci::Position position = pdoc->LineStart(LineFromLocation(pt));
- if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) {
- const bool ctrl = (modifiers & SCI_CTRL) != 0;
- const bool shift = (modifiers & SCI_SHIFT) != 0;
+ if ((vs.ms[marginClicked].mask & MaskFolders) && (FlagSet(foldAutomatic, AutomaticFold::Click))) {
+ const bool ctrl = FlagSet(modifiers, KeyMod::Ctrl);
+ const bool shift = FlagSet(modifiers, KeyMod::Shift);
const Sci::Line lineClick = pdoc->SciLineFromPosition(position);
if (shift && ctrl) {
- FoldAll(SC_FOLDACTION_TOGGLE);
+ FoldAll(FoldAction::Toggle);
} else {
- const int levelClick = pdoc->GetLevel(lineClick);
+ const FoldLevel levelClick = pdoc->GetFoldLevel(lineClick);
if (LevelIsHeader(levelClick)) {
if (shift) {
// Ensure all children visible
- FoldExpand(lineClick, SC_FOLDACTION_EXPAND, levelClick);
+ FoldExpand(lineClick, FoldAction::Expand, levelClick);
} else if (ctrl) {
- FoldExpand(lineClick, SC_FOLDACTION_TOGGLE, levelClick);
+ FoldExpand(lineClick, FoldAction::Toggle, levelClick);
} else {
// Toggle this line
- FoldLine(lineClick, SC_FOLDACTION_TOGGLE);
+ FoldLine(lineClick, FoldAction::Toggle);
}
}
}
return true;
}
- SCNotification scn = {};
- scn.nmhdr.code = SCN_MARGINCLICK;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::MarginClick;
scn.modifiers = modifiers;
scn.position = position;
scn.margin = marginClicked;
@@ -2488,12 +2483,12 @@ bool Editor::NotifyMarginClick(Point pt, int modifiers) {
}
}
-bool Editor::NotifyMarginRightClick(Point pt, int modifiers) {
+bool Editor::NotifyMarginRightClick(Point pt, KeyMod modifiers) {
const int marginRightClicked = vs.MarginFromLocation(pt);
if ((marginRightClicked >= 0) && vs.ms[marginRightClicked].sensitive) {
const Sci::Position position = pdoc->LineStart(LineFromLocation(pt));
- SCNotification scn = {};
- scn.nmhdr.code = SCN_MARGINRIGHTCLICK;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::MarginRightClick;
scn.modifiers = modifiers;
scn.position = position;
scn.margin = marginRightClicked;
@@ -2505,16 +2500,16 @@ bool Editor::NotifyMarginRightClick(Point pt, int modifiers) {
}
void Editor::NotifyNeedShown(Sci::Position pos, Sci::Position len) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_NEEDSHOWN;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::NeedShown;
scn.position = pos;
scn.length = len;
NotifyParent(scn);
}
void Editor::NotifyDwelling(Point pt, bool state) {
- SCNotification scn = {};
- scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND;
+ NotificationData scn = {};
+ scn.nmhdr.code = state ? Notification::DwellStart : Notification::DwellEnd;
scn.position = PositionFromLocation(pt, true);
scn.x = static_cast<int>(pt.x + vs.ExternalMarginWidth());
scn.y = static_cast<int>(pt.y);
@@ -2522,8 +2517,8 @@ void Editor::NotifyDwelling(Point pt, bool state) {
}
void Editor::NotifyZoom() {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_ZOOM;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::Zoom;
NotifyParent(scn);
}
@@ -2539,7 +2534,7 @@ void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) {
}
void Editor::CheckModificationForWrap(DocModification mh) {
- if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
+ if (FlagSet(mh.modificationType, ModificationFlags::InsertText | ModificationFlags::DeleteText)) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position);
const Sci::Line lines = std::max(static_cast<Sci::Line>(0), mh.linesAdded);
@@ -2580,11 +2575,11 @@ constexpr Sci::Position MovePositionForDeletion(Sci::Position position, Sci::Pos
}
void Editor::NotifyModified(Document *, DocModification mh, void *) {
- ContainerNeedsUpdate(SC_UPDATE_CONTENT);
+ ContainerNeedsUpdate(Update::Content);
if (paintState == PaintState::painting) {
CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
}
- if (mh.modificationType & SC_MOD_CHANGELINESTATE) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeLineState)) {
if (paintState == PaintState::painting) {
CheckForChangeOutsidePaint(
Range(pdoc->LineStart(mh.line),
@@ -2594,10 +2589,10 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
Redraw();
}
}
- if (mh.modificationType & SC_MOD_CHANGETABSTOPS) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeTabStops)) {
Redraw();
}
- if (mh.modificationType & SC_MOD_LEXERSTATE) {
+ if (FlagSet(mh.modificationType, ModificationFlags::LexerState)) {
if (paintState == PaintState::painting) {
CheckForChangeOutsidePaint(
Range(mh.position, mh.position + mh.length));
@@ -2605,8 +2600,8 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
Redraw();
}
}
- if (mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) {
- if (mh.modificationType & SC_MOD_CHANGESTYLE) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeStyle | ModificationFlags::ChangeIndicator)) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeStyle)) {
pdoc->IncrementStyleClock();
}
if (paintState == PaintState::notPainting) {
@@ -2618,33 +2613,33 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
InvalidateRange(mh.position, mh.position + mh.length);
}
}
- if (mh.modificationType & SC_MOD_CHANGESTYLE) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeStyle)) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
}
} else {
// Move selection and brace highlights
- if (mh.modificationType & SC_MOD_INSERTTEXT) {
+ if (FlagSet(mh.modificationType, ModificationFlags::InsertText)) {
sel.MovePositions(true, mh.position, mh.length);
braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length);
braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length);
- } else if (mh.modificationType & SC_MOD_DELETETEXT) {
+ } else if (FlagSet(mh.modificationType, ModificationFlags::DeleteText)) {
sel.MovePositions(false, mh.position, mh.length);
braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length);
braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length);
}
- if ((mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) && pcs->HiddenLines()) {
+ if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete) && pcs->HiddenLines()) {
// Some lines are hidden so may need shown.
const Sci::Line lineOfPos = pdoc->SciLineFromPosition(mh.position);
Sci::Position endNeedShown = mh.position;
- if (mh.modificationType & SC_MOD_BEFOREINSERT) {
+ 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 (mh.modificationType & SC_MOD_BEFOREDELETE) {
+ } else if (FlagSet(mh.modificationType, ModificationFlags::BeforeDelete)) {
// 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);
for (Sci::Line line = lineOfPos + 1; line <= lineLast; line++) {
- const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1, -1);
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, {}, -1);
if (lineLast < lineMaxSubord) {
lineLast = lineMaxSubord;
endNeedShown = pdoc->LineEnd(lineLast);
@@ -2666,17 +2661,17 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
}
view.LinesAddedOrRemoved(lineOfPos, mh.linesAdded);
}
- if (mh.modificationType & SC_MOD_CHANGEANNOTATION) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeAnnotation)) {
const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position);
- if (vs.annotationVisible) {
+ if (vs.annotationVisible != AnnotationVisible::Hidden) {
if (pcs->SetHeight(lineDoc, pcs->GetHeight(lineDoc) + static_cast<int>(mh.annotationLinesAdded))) {
SetScrollBars();
}
Redraw();
}
}
- if (mh.modificationType & SC_MOD_CHANGEEOLANNOTATION) {
- if (vs.eolAnnotationVisible) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeEOLAnnotation)) {
+ if (vs.eolAnnotationVisible != EOLAnnotationVisible::Hidden) {
Redraw();
}
}
@@ -2711,9 +2706,9 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
SetScrollBars();
}
- if ((mh.modificationType & SC_MOD_CHANGEMARKER) || (mh.modificationType & SC_MOD_CHANGEMARGIN)) {
+ if ((FlagSet(mh.modificationType, ModificationFlags::ChangeMarker)) || (FlagSet(mh.modificationType, ModificationFlags::ChangeMargin))) {
if ((!willRedrawAll) && ((paintState == PaintState::notPainting) || !PaintContainsMargin())) {
- if (mh.modificationType & SC_MOD_CHANGEFOLD) {
+ if (FlagSet(mh.modificationType, ModificationFlags::ChangeFold)) {
// Fold changes can affect the drawing of following lines so redraw whole margin
RedrawSelMargin(marginView.highlightDelimiter.isEnabled ? -1 : mh.line - 1, true);
} else {
@@ -2721,7 +2716,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
}
}
}
- if ((mh.modificationType & SC_MOD_CHANGEFOLD) && (foldAutomatic & SC_AUTOMATICFOLD_CHANGE)) {
+ if ((FlagSet(mh.modificationType, ModificationFlags::ChangeFold)) && (FlagSet(foldAutomatic, AutomaticFold::Change))) {
FoldChanged(mh.line, mh.foldLevelNow, mh.foldLevelPrev);
}
@@ -2732,16 +2727,16 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
}
// If client wants to see this modification
- if (mh.modificationType & modEventMask) {
+ if (FlagSet(mh.modificationType, modEventMask)) {
if (commandEvents) {
- if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
+ if ((mh.modificationType & (ModificationFlags::ChangeStyle | ModificationFlags::ChangeIndicator)) == ModificationFlags::None) {
// Real modification made to text of document.
NotifyChange(); // Send EN_CHANGE
}
}
- SCNotification scn = {};
- scn.nmhdr.code = SCN_MODIFIED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::Modified;
scn.position = mh.position;
scn.modificationType = mh.modificationType;
scn.text = mh.text;
@@ -2760,131 +2755,131 @@ void Editor::NotifyDeleted(Document *, void *) noexcept {
/* Do nothing */
}
-void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+void Editor::NotifyMacroRecord(Message iMessage, uptr_t wParam, sptr_t lParam) {
// Enumerates all macroable messages
switch (iMessage) {
- case SCI_CUT:
- case SCI_COPY:
- case SCI_PASTE:
- case SCI_CLEAR:
- case SCI_REPLACESEL:
- case SCI_ADDTEXT:
- case SCI_INSERTTEXT:
- case SCI_APPENDTEXT:
- case SCI_CLEARALL:
- case SCI_SELECTALL:
- case SCI_GOTOLINE:
- case SCI_GOTOPOS:
- case SCI_SEARCHANCHOR:
- case SCI_SEARCHNEXT:
- case SCI_SEARCHPREV:
- case SCI_LINEDOWN:
- case SCI_LINEDOWNEXTEND:
- case SCI_PARADOWN:
- case SCI_PARADOWNEXTEND:
- case SCI_LINEUP:
- case SCI_LINEUPEXTEND:
- case SCI_PARAUP:
- case SCI_PARAUPEXTEND:
- case SCI_CHARLEFT:
- case SCI_CHARLEFTEXTEND:
- case SCI_CHARRIGHT:
- case SCI_CHARRIGHTEXTEND:
- case SCI_WORDLEFT:
- case SCI_WORDLEFTEXTEND:
- case SCI_WORDRIGHT:
- case SCI_WORDRIGHTEXTEND:
- case SCI_WORDPARTLEFT:
- case SCI_WORDPARTLEFTEXTEND:
- case SCI_WORDPARTRIGHT:
- case SCI_WORDPARTRIGHTEXTEND:
- case SCI_WORDLEFTEND:
- case SCI_WORDLEFTENDEXTEND:
- case SCI_WORDRIGHTEND:
- case SCI_WORDRIGHTENDEXTEND:
- case SCI_HOME:
- case SCI_HOMEEXTEND:
- case SCI_LINEEND:
- case SCI_LINEENDEXTEND:
- case SCI_HOMEWRAP:
- case SCI_HOMEWRAPEXTEND:
- case SCI_LINEENDWRAP:
- case SCI_LINEENDWRAPEXTEND:
- case SCI_DOCUMENTSTART:
- case SCI_DOCUMENTSTARTEXTEND:
- case SCI_DOCUMENTEND:
- case SCI_DOCUMENTENDEXTEND:
- case SCI_STUTTEREDPAGEUP:
- case SCI_STUTTEREDPAGEUPEXTEND:
- case SCI_STUTTEREDPAGEDOWN:
- case SCI_STUTTEREDPAGEDOWNEXTEND:
- case SCI_PAGEUP:
- case SCI_PAGEUPEXTEND:
- case SCI_PAGEDOWN:
- case SCI_PAGEDOWNEXTEND:
- case SCI_EDITTOGGLEOVERTYPE:
- case SCI_CANCEL:
- case SCI_DELETEBACK:
- case SCI_TAB:
- case SCI_BACKTAB:
- case SCI_FORMFEED:
- case SCI_VCHOME:
- case SCI_VCHOMEEXTEND:
- case SCI_VCHOMEWRAP:
- case SCI_VCHOMEWRAPEXTEND:
- case SCI_VCHOMEDISPLAY:
- case SCI_VCHOMEDISPLAYEXTEND:
- case SCI_DELWORDLEFT:
- case SCI_DELWORDRIGHT:
- case SCI_DELWORDRIGHTEND:
- case SCI_DELLINELEFT:
- case SCI_DELLINERIGHT:
- case SCI_LINECOPY:
- case SCI_LINECUT:
- case SCI_LINEDELETE:
- case SCI_LINETRANSPOSE:
- case SCI_LINEREVERSE:
- case SCI_LINEDUPLICATE:
- case SCI_LOWERCASE:
- case SCI_UPPERCASE:
- case SCI_LINESCROLLDOWN:
- case SCI_LINESCROLLUP:
- case SCI_DELETEBACKNOTLINE:
- case SCI_HOMEDISPLAY:
- case SCI_HOMEDISPLAYEXTEND:
- case SCI_LINEENDDISPLAY:
- case SCI_LINEENDDISPLAYEXTEND:
- case SCI_SETSELECTIONMODE:
- case SCI_LINEDOWNRECTEXTEND:
- case SCI_LINEUPRECTEXTEND:
- case SCI_CHARLEFTRECTEXTEND:
- case SCI_CHARRIGHTRECTEXTEND:
- case SCI_HOMERECTEXTEND:
- case SCI_VCHOMERECTEXTEND:
- case SCI_LINEENDRECTEXTEND:
- case SCI_PAGEUPRECTEXTEND:
- case SCI_PAGEDOWNRECTEXTEND:
- case SCI_SELECTIONDUPLICATE:
- case SCI_COPYALLOWLINE:
- case SCI_VERTICALCENTRECARET:
- case SCI_MOVESELECTEDLINESUP:
- case SCI_MOVESELECTEDLINESDOWN:
- case SCI_SCROLLTOSTART:
- case SCI_SCROLLTOEND:
+ case Message::Cut:
+ case Message::Copy:
+ case Message::Paste:
+ case Message::Clear:
+ case Message::ReplaceSel:
+ case Message::AddText:
+ case Message::InsertText:
+ case Message::AppendText:
+ case Message::ClearAll:
+ case Message::SelectAll:
+ case Message::GotoLine:
+ case Message::GotoPos:
+ case Message::SearchAnchor:
+ case Message::SearchNext:
+ case Message::SearchPrev:
+ case Message::LineDown:
+ case Message::LineDownExtend:
+ case Message::ParaDown:
+ case Message::ParaDownExtend:
+ case Message::LineUp:
+ case Message::LineUpExtend:
+ case Message::ParaUp:
+ case Message::ParaUpExtend:
+ case Message::CharLeft:
+ case Message::CharLeftExtend:
+ case Message::CharRight:
+ case Message::CharRightExtend:
+ case Message::WordLeft:
+ case Message::WordLeftExtend:
+ case Message::WordRight:
+ case Message::WordRightExtend:
+ case Message::WordPartLeft:
+ case Message::WordPartLeftExtend:
+ case Message::WordPartRight:
+ case Message::WordPartRightExtend:
+ case Message::WordLeftEnd:
+ case Message::WordLeftEndExtend:
+ case Message::WordRightEnd:
+ case Message::WordRightEndExtend:
+ case Message::Home:
+ case Message::HomeExtend:
+ case Message::LineEnd:
+ case Message::LineEndExtend:
+ case Message::HomeWrap:
+ case Message::HomeWrapExtend:
+ case Message::LineEndWrap:
+ case Message::LineEndWrapExtend:
+ case Message::DocumentStart:
+ case Message::DocumentStartExtend:
+ case Message::DocumentEnd:
+ case Message::DocumentEndExtend:
+ case Message::StutteredPageUp:
+ case Message::StutteredPageUpExtend:
+ case Message::StutteredPageDown:
+ case Message::StutteredPageDownExtend:
+ case Message::PageUp:
+ case Message::PageUpExtend:
+ case Message::PageDown:
+ case Message::PageDownExtend:
+ case Message::EditToggleOvertype:
+ case Message::Cancel:
+ case Message::DeleteBack:
+ case Message::Tab:
+ case Message::BackTab:
+ case Message::FormFeed:
+ case Message::VCHome:
+ case Message::VCHomeExtend:
+ case Message::VCHomeWrap:
+ case Message::VCHomeWrapExtend:
+ case Message::VCHomeDisplay:
+ case Message::VCHomeDisplayExtend:
+ case Message::DelWordLeft:
+ case Message::DelWordRight:
+ case Message::DelWordRightEnd:
+ case Message::DelLineLeft:
+ case Message::DelLineRight:
+ case Message::LineCopy:
+ case Message::LineCut:
+ case Message::LineDelete:
+ case Message::LineTranspose:
+ case Message::LineReverse:
+ case Message::LineDuplicate:
+ case Message::LowerCase:
+ case Message::UpperCase:
+ case Message::LineScrollDown:
+ case Message::LineScrollUp:
+ case Message::DeleteBackNotLine:
+ case Message::HomeDisplay:
+ case Message::HomeDisplayExtend:
+ case Message::LineEndDisplay:
+ case Message::LineEndDisplayExtend:
+ case Message::SetSelectionMode:
+ case Message::LineDownRectExtend:
+ case Message::LineUpRectExtend:
+ case Message::CharLeftRectExtend:
+ case Message::CharRightRectExtend:
+ case Message::HomeRectExtend:
+ case Message::VCHomeRectExtend:
+ case Message::LineEndRectExtend:
+ case Message::PageUpRectExtend:
+ case Message::PageDownRectExtend:
+ case Message::SelectionDuplicate:
+ case Message::CopyAllowLine:
+ case Message::VerticalCentreCaret:
+ case Message::MoveSelectedLinesUp:
+ case Message::MoveSelectedLinesDown:
+ case Message::ScrollToStart:
+ case Message::ScrollToEnd:
break;
// Filter out all others like display changes. Also, newlines are redundant
// with char insert messages.
- case SCI_NEWLINE:
+ case Message::NewLine:
default:
// printf("Filtered out %ld of macro recording\n", iMessage);
return;
}
// Send notification
- SCNotification scn = {};
- scn.nmhdr.code = SCN_MACRORECORD;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::MacroRecord;
scn.message = iMessage;
scn.wParam = wParam;
scn.lParam = lParam;
@@ -2892,8 +2887,8 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar
}
// Something has changed that the container should know about
-void Editor::ContainerNeedsUpdate(int flags) noexcept {
- needUpdateUI |= flags;
+void Editor::ContainerNeedsUpdate(Update flags) noexcept {
+ needUpdateUI = needUpdateUI | flags;
}
/**
@@ -3118,12 +3113,12 @@ void Editor::NewLine() {
for (size_t i = 0; i < countInsertions; i++) {
const char *eol = StringFromEOLMode(pdoc->eolMode);
while (*eol) {
- NotifyChar(*eol, CharacterSource::directInput);
+ NotifyChar(*eol, CharacterSource::DirectInput);
if (recordingMacro) {
char txt[2];
txt[0] = *eol;
txt[1] = '\0';
- NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(txt));
+ NotifyMacroRecord(Message::ReplaceSel, 0, reinterpret_cast<sptr_t>(txt));
}
eol++;
}
@@ -3140,7 +3135,7 @@ SelectionPosition Editor::PositionUpOrDown(SelectionPosition spStart, int direct
const Point pt = LocationFromPosition(spStart);
int skipLines = 0;
- if (vs.annotationVisible) {
+ if (vs.annotationVisible != AnnotationVisible::Hidden) {
const Sci::Line lineDoc = pdoc->SciLineFromPosition(spStart.Position());
const Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
const int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight;
@@ -3276,57 +3271,57 @@ constexpr short LowShortFromWParam(uptr_t x) {
return static_cast<short>(x & 0xffff);
}
-constexpr unsigned int WithExtends(unsigned int iMessage) noexcept {
+constexpr Message WithExtends(Message iMessage) noexcept {
switch (iMessage) {
- case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND;
- case SCI_CHARRIGHT: return SCI_CHARRIGHTEXTEND;
-
- case SCI_WORDLEFT: return SCI_WORDLEFTEXTEND;
- case SCI_WORDRIGHT: return SCI_WORDRIGHTEXTEND;
- case SCI_WORDLEFTEND: return SCI_WORDLEFTENDEXTEND;
- case SCI_WORDRIGHTEND: return SCI_WORDRIGHTENDEXTEND;
- case SCI_WORDPARTLEFT: return SCI_WORDPARTLEFTEXTEND;
- case SCI_WORDPARTRIGHT: return SCI_WORDPARTRIGHTEXTEND;
-
- case SCI_HOME: return SCI_HOMEEXTEND;
- case SCI_HOMEDISPLAY: return SCI_HOMEDISPLAYEXTEND;
- case SCI_HOMEWRAP: return SCI_HOMEWRAPEXTEND;
- case SCI_VCHOME: return SCI_VCHOMEEXTEND;
- case SCI_VCHOMEDISPLAY: return SCI_VCHOMEDISPLAYEXTEND;
- case SCI_VCHOMEWRAP: return SCI_VCHOMEWRAPEXTEND;
-
- case SCI_LINEEND: return SCI_LINEENDEXTEND;
- case SCI_LINEENDDISPLAY: return SCI_LINEENDDISPLAYEXTEND;
- case SCI_LINEENDWRAP: return SCI_LINEENDWRAPEXTEND;
+ case Message::CharLeft: return Message::CharLeftExtend;
+ case Message::CharRight: return Message::CharRightExtend;
+
+ case Message::WordLeft: return Message::WordLeftExtend;
+ case Message::WordRight: return Message::WordRightExtend;
+ case Message::WordLeftEnd: return Message::WordLeftEndExtend;
+ case Message::WordRightEnd: return Message::WordRightEndExtend;
+ case Message::WordPartLeft: return Message::WordPartLeftExtend;
+ case Message::WordPartRight: return Message::WordPartRightExtend;
+
+ case Message::Home: return Message::HomeExtend;
+ case Message::HomeDisplay: return Message::HomeDisplayExtend;
+ case Message::HomeWrap: return Message::HomeWrapExtend;
+ case Message::VCHome: return Message::VCHomeExtend;
+ case Message::VCHomeDisplay: return Message::VCHomeDisplayExtend;
+ case Message::VCHomeWrap: return Message::VCHomeWrapExtend;
+
+ case Message::LineEnd: return Message::LineEndExtend;
+ case Message::LineEndDisplay: return Message::LineEndDisplayExtend;
+ case Message::LineEndWrap: return Message::LineEndWrapExtend;
default: return iMessage;
}
}
-constexpr int NaturalDirection(unsigned int iMessage) noexcept {
+constexpr int NaturalDirection(Message iMessage) noexcept {
switch (iMessage) {
- case SCI_CHARLEFT:
- case SCI_CHARLEFTEXTEND:
- case SCI_CHARLEFTRECTEXTEND:
- case SCI_WORDLEFT:
- case SCI_WORDLEFTEXTEND:
- case SCI_WORDLEFTEND:
- case SCI_WORDLEFTENDEXTEND:
- case SCI_WORDPARTLEFT:
- case SCI_WORDPARTLEFTEXTEND:
- case SCI_HOME:
- case SCI_HOMEEXTEND:
- case SCI_HOMEDISPLAY:
- case SCI_HOMEDISPLAYEXTEND:
- case SCI_HOMEWRAP:
- case SCI_HOMEWRAPEXTEND:
+ case Message::CharLeft:
+ case Message::CharLeftExtend:
+ case Message::CharLeftRectExtend:
+ case Message::WordLeft:
+ case Message::WordLeftExtend:
+ case Message::WordLeftEnd:
+ case Message::WordLeftEndExtend:
+ case Message::WordPartLeft:
+ case Message::WordPartLeftExtend:
+ case Message::Home:
+ case Message::HomeExtend:
+ case Message::HomeDisplay:
+ case Message::HomeDisplayExtend:
+ case Message::HomeWrap:
+ case Message::HomeWrapExtend:
// VC_HOME* mostly goes back
- case SCI_VCHOME:
- case SCI_VCHOMEEXTEND:
- case SCI_VCHOMEDISPLAY:
- case SCI_VCHOMEDISPLAYEXTEND:
- case SCI_VCHOMEWRAP:
- case SCI_VCHOMEWRAPEXTEND:
+ case Message::VCHome:
+ case Message::VCHomeExtend:
+ case Message::VCHomeDisplay:
+ case Message::VCHomeDisplayExtend:
+ case Message::VCHomeWrap:
+ case Message::VCHomeWrapExtend:
return -1;
default:
@@ -3334,23 +3329,23 @@ constexpr int NaturalDirection(unsigned int iMessage) noexcept {
}
}
-constexpr bool IsRectExtend(unsigned int iMessage, bool isRectMoveExtends) noexcept {
+constexpr bool IsRectExtend(Message iMessage, bool isRectMoveExtends) noexcept {
switch (iMessage) {
- case SCI_CHARLEFTRECTEXTEND:
- case SCI_CHARRIGHTRECTEXTEND:
- case SCI_HOMERECTEXTEND:
- case SCI_VCHOMERECTEXTEND:
- case SCI_LINEENDRECTEXTEND:
+ case Message::CharLeftRectExtend:
+ case Message::CharRightRectExtend:
+ case Message::HomeRectExtend:
+ case Message::VCHomeRectExtend:
+ case Message::LineEndRectExtend:
return true;
default:
if (isRectMoveExtends) {
- // Handle SCI_SETSELECTIONMODE(SC_SEL_RECTANGLE) and subsequent movements.
+ // Handle Message::SetSelectionMode(SelectionMode::Rectangle) and subsequent movements.
switch (iMessage) {
- case SCI_CHARLEFTEXTEND:
- case SCI_CHARRIGHTEXTEND:
- case SCI_HOMEEXTEND:
- case SCI_VCHOMEEXTEND:
- case SCI_LINEENDEXTEND:
+ case Message::CharLeftExtend:
+ case Message::CharRightExtend:
+ case Message::HomeExtend:
+ case Message::VCHomeExtend:
+ case Message::LineEndExtend:
return true;
default:
return false;
@@ -3390,7 +3385,7 @@ Sci::Position Editor::LineEndWrapPosition(Sci::Position position) {
return endPos;
}
-int Editor::HorizontalMove(unsigned int iMessage) {
+int Editor::HorizontalMove(Message iMessage) {
if (sel.selType == Selection::SelTypes::lines) {
return 0; // horizontal moves with line selection have no effect
}
@@ -3414,35 +3409,37 @@ int Editor::HorizontalMove(unsigned int iMessage) {
// Will change to rectangular if not currently rectangular
SelectionPosition spCaret = rangeBase.caret;
switch (iMessage) {
- case SCI_CHARLEFTRECTEXTEND:
- case SCI_CHARLEFTEXTEND: // only when sel.IsRectangular() && sel.MoveExtends()
+ case Message::CharLeftRectExtend:
+ case Message::CharLeftExtend: // only when sel.IsRectangular() && sel.MoveExtends()
if (pdoc->IsLineEndPosition(spCaret.Position()) && spCaret.VirtualSpace()) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
- } else if ((virtualSpaceOptions & SCVS_NOWRAPLINESTART) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) {
+ } else if ((FlagSet(virtualSpaceOptions, VirtualSpace::NoWrapLineStart)) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) {
spCaret = SelectionPosition(spCaret.Position() - 1);
}
break;
- case SCI_CHARRIGHTRECTEXTEND:
- case SCI_CHARRIGHTEXTEND: // only when sel.IsRectangular() && sel.MoveExtends()
- if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) {
+ case Message::CharRightRectExtend:
+ case Message::CharRightExtend: // only when sel.IsRectangular() && sel.MoveExtends()
+ if ((FlagSet(virtualSpaceOptions, VirtualSpace::RectangularSelection)) && pdoc->IsLineEndPosition(sel.MainCaret())) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
} else {
spCaret = SelectionPosition(spCaret.Position() + 1);
}
break;
- case SCI_HOMERECTEXTEND:
- case SCI_HOMEEXTEND: // only when sel.IsRectangular() && sel.MoveExtends()
+ case Message::HomeRectExtend:
+ case Message::HomeExtend: // only when sel.IsRectangular() && sel.MoveExtends()
spCaret = SelectionPosition(
pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position())));
break;
- case SCI_VCHOMERECTEXTEND:
- case SCI_VCHOMEEXTEND: // only when sel.IsRectangular() && sel.MoveExtends()
+ case Message::VCHomeRectExtend:
+ case Message::VCHomeExtend: // only when sel.IsRectangular() && sel.MoveExtends()
spCaret = SelectionPosition(pdoc->VCHomePosition(spCaret.Position()));
break;
- case SCI_LINEENDRECTEXTEND:
- case SCI_LINEENDEXTEND: // only when sel.IsRectangular() && sel.MoveExtends()
+ case Message::LineEndRectExtend:
+ case Message::LineEndExtend: // only when sel.IsRectangular() && sel.MoveExtends()
spCaret = SelectionPosition(pdoc->LineEndPosition(spCaret.Position()));
break;
+ default:
+ break;
}
const int directionMove = (spCaret < rangeBase.caret) ? -1 : 1;
spCaret = MovePositionSoVisible(spCaret, directionMove);
@@ -3453,16 +3450,18 @@ int Editor::HorizontalMove(unsigned int iMessage) {
// Not a rectangular extension so switch to stream.
SelectionPosition selAtLimit = (NaturalDirection(iMessage) > 0) ? sel.Limits().end : sel.Limits().start;
switch (iMessage) {
- case SCI_HOME:
+ case Message::Home:
selAtLimit = SelectionPosition(
pdoc->LineStart(pdoc->LineFromPosition(selAtLimit.Position())));
break;
- case SCI_VCHOME:
+ case Message::VCHome:
selAtLimit = SelectionPosition(pdoc->VCHomePosition(selAtLimit.Position()));
break;
- case SCI_LINEEND:
+ case Message::LineEnd:
selAtLimit = SelectionPosition(pdoc->LineEndPosition(selAtLimit.Position()));
break;
+ default:
+ break;
}
sel.selType = Selection::SelTypes::stream;
sel.SetSelection(SelectionRange(selAtLimit));
@@ -3475,85 +3474,85 @@ int Editor::HorizontalMove(unsigned int iMessage) {
const SelectionPosition spCaretNow = sel.Range(r).caret;
SelectionPosition spCaret = spCaretNow;
switch (iMessage) {
- case SCI_CHARLEFT:
- case SCI_CHARLEFTEXTEND:
+ case Message::CharLeft:
+ case Message::CharLeftExtend:
if (spCaret.VirtualSpace()) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
- } else if ((virtualSpaceOptions & SCVS_NOWRAPLINESTART) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) {
+ } else if ((FlagSet(virtualSpaceOptions, VirtualSpace::NoWrapLineStart)) == 0 || pdoc->GetColumn(spCaret.Position()) > 0) {
spCaret = SelectionPosition(spCaret.Position() - 1);
}
break;
- case SCI_CHARRIGHT:
- case SCI_CHARRIGHTEXTEND:
- if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(spCaret.Position())) {
+ case Message::CharRight:
+ case Message::CharRightExtend:
+ if ((FlagSet(virtualSpaceOptions, VirtualSpace::UserAccessible)) && pdoc->IsLineEndPosition(spCaret.Position())) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
} else {
spCaret = SelectionPosition(spCaret.Position() + 1);
}
break;
- case SCI_WORDLEFT:
- case SCI_WORDLEFTEXTEND:
+ case Message::WordLeft:
+ case Message::WordLeftExtend:
spCaret = SelectionPosition(pdoc->NextWordStart(spCaret.Position(), -1));
break;
- case SCI_WORDRIGHT:
- case SCI_WORDRIGHTEXTEND:
+ case Message::WordRight:
+ case Message::WordRightExtend:
spCaret = SelectionPosition(pdoc->NextWordStart(spCaret.Position(), 1));
break;
- case SCI_WORDLEFTEND:
- case SCI_WORDLEFTENDEXTEND:
+ case Message::WordLeftEnd:
+ case Message::WordLeftEndExtend:
spCaret = SelectionPosition(pdoc->NextWordEnd(spCaret.Position(), -1));
break;
- case SCI_WORDRIGHTEND:
- case SCI_WORDRIGHTENDEXTEND:
+ case Message::WordRightEnd:
+ case Message::WordRightEndExtend:
spCaret = SelectionPosition(pdoc->NextWordEnd(spCaret.Position(), 1));
break;
- case SCI_WORDPARTLEFT:
- case SCI_WORDPARTLEFTEXTEND:
+ case Message::WordPartLeft:
+ case Message::WordPartLeftExtend:
spCaret = SelectionPosition(pdoc->WordPartLeft(spCaret.Position()));
break;
- case SCI_WORDPARTRIGHT:
- case SCI_WORDPARTRIGHTEXTEND:
+ case Message::WordPartRight:
+ case Message::WordPartRightExtend:
spCaret = SelectionPosition(pdoc->WordPartRight(spCaret.Position()));
break;
- case SCI_HOME:
- case SCI_HOMEEXTEND:
+ case Message::Home:
+ case Message::HomeExtend:
spCaret = SelectionPosition(
pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position())));
break;
- case SCI_HOMEDISPLAY:
- case SCI_HOMEDISPLAYEXTEND:
+ case Message::HomeDisplay:
+ case Message::HomeDisplayExtend:
spCaret = SelectionPosition(StartEndDisplayLine(spCaret.Position(), true));
break;
- case SCI_HOMEWRAP:
- case SCI_HOMEWRAPEXTEND:
+ case Message::HomeWrap:
+ case Message::HomeWrapExtend:
spCaret = MovePositionSoVisible(StartEndDisplayLine(spCaret.Position(), true), -1);
if (spCaretNow <= spCaret)
spCaret = SelectionPosition(
pdoc->LineStart(pdoc->LineFromPosition(spCaret.Position())));
break;
- case SCI_VCHOME:
- case SCI_VCHOMEEXTEND:
+ case Message::VCHome:
+ case Message::VCHomeExtend:
// VCHome alternates between beginning of line and beginning of text so may move back or forwards
spCaret = SelectionPosition(pdoc->VCHomePosition(spCaret.Position()));
break;
- case SCI_VCHOMEDISPLAY:
- case SCI_VCHOMEDISPLAYEXTEND:
+ case Message::VCHomeDisplay:
+ case Message::VCHomeDisplayExtend:
spCaret = SelectionPosition(VCHomeDisplayPosition(spCaret.Position()));
break;
- case SCI_VCHOMEWRAP:
- case SCI_VCHOMEWRAPEXTEND:
+ case Message::VCHomeWrap:
+ case Message::VCHomeWrapExtend:
spCaret = SelectionPosition(VCHomeWrapPosition(spCaret.Position()));
break;
- case SCI_LINEEND:
- case SCI_LINEENDEXTEND:
+ case Message::LineEnd:
+ case Message::LineEndExtend:
spCaret = SelectionPosition(pdoc->LineEndPosition(spCaret.Position()));
break;
- case SCI_LINEENDDISPLAY:
- case SCI_LINEENDDISPLAYEXTEND:
+ case Message::LineEndDisplay:
+ case Message::LineEndDisplayExtend:
spCaret = SelectionPosition(StartEndDisplayLine(spCaret.Position(), false));
break;
- case SCI_LINEENDWRAP:
- case SCI_LINEENDWRAPEXTEND:
+ case Message::LineEndWrap:
+ case Message::LineEndWrapExtend:
spCaret = SelectionPosition(LineEndWrapPosition(spCaret.Position()));
break;
@@ -3566,51 +3565,51 @@ int Editor::HorizontalMove(unsigned int iMessage) {
// Handle move versus extend, and special behaviour for non-empty left/right
switch (iMessage) {
- case SCI_CHARLEFT:
- case SCI_CHARRIGHT:
+ case Message::CharLeft:
+ case Message::CharRight:
if (sel.Range(r).Empty()) {
sel.Range(r) = SelectionRange(spCaret);
} else {
sel.Range(r) = SelectionRange(
- (iMessage == SCI_CHARLEFT) ? sel.Range(r).Start() : sel.Range(r).End());
+ (iMessage == Message::CharLeft) ? sel.Range(r).Start() : sel.Range(r).End());
}
break;
- case SCI_WORDLEFT:
- case SCI_WORDRIGHT:
- case SCI_WORDLEFTEND:
- case SCI_WORDRIGHTEND:
- case SCI_WORDPARTLEFT:
- case SCI_WORDPARTRIGHT:
- case SCI_HOME:
- case SCI_HOMEDISPLAY:
- case SCI_HOMEWRAP:
- case SCI_VCHOME:
- case SCI_VCHOMEDISPLAY:
- case SCI_VCHOMEWRAP:
- case SCI_LINEEND:
- case SCI_LINEENDDISPLAY:
- case SCI_LINEENDWRAP:
+ case Message::WordLeft:
+ case Message::WordRight:
+ case Message::WordLeftEnd:
+ case Message::WordRightEnd:
+ case Message::WordPartLeft:
+ case Message::WordPartRight:
+ case Message::Home:
+ case Message::HomeDisplay:
+ case Message::HomeWrap:
+ case Message::VCHome:
+ case Message::VCHomeDisplay:
+ case Message::VCHomeWrap:
+ case Message::LineEnd:
+ case Message::LineEndDisplay:
+ case Message::LineEndWrap:
sel.Range(r) = SelectionRange(spCaret);
break;
- case SCI_CHARLEFTEXTEND:
- case SCI_CHARRIGHTEXTEND:
- case SCI_WORDLEFTEXTEND:
- case SCI_WORDRIGHTEXTEND:
- case SCI_WORDLEFTENDEXTEND:
- case SCI_WORDRIGHTENDEXTEND:
- case SCI_WORDPARTLEFTEXTEND:
- case SCI_WORDPARTRIGHTEXTEND:
- case SCI_HOMEEXTEND:
- case SCI_HOMEDISPLAYEXTEND:
- case SCI_HOMEWRAPEXTEND:
- case SCI_VCHOMEEXTEND:
- case SCI_VCHOMEDISPLAYEXTEND:
- case SCI_VCHOMEWRAPEXTEND:
- case SCI_LINEENDEXTEND:
- case SCI_LINEENDDISPLAYEXTEND:
- case SCI_LINEENDWRAPEXTEND: {
+ case Message::CharLeftExtend:
+ case Message::CharRightExtend:
+ case Message::WordLeftExtend:
+ case Message::WordRightExtend:
+ case Message::WordLeftEndExtend:
+ case Message::WordRightEndExtend:
+ case Message::WordPartLeftExtend:
+ case Message::WordPartRightExtend:
+ case Message::HomeExtend:
+ case Message::HomeDisplayExtend:
+ case Message::HomeWrapExtend:
+ case Message::VCHomeExtend:
+ case Message::VCHomeDisplayExtend:
+ case Message::VCHomeWrapExtend:
+ case Message::LineEndExtend:
+ case Message::LineEndDisplayExtend:
+ case Message::LineEndWrapExtend: {
SelectionRange rangeNew = SelectionRange(spCaret, sel.Range(r).anchor);
sel.TrimOtherSelections(r, SelectionRange(rangeNew));
sel.Range(r) = rangeNew;
@@ -3635,13 +3634,13 @@ int Editor::HorizontalMove(unsigned int iMessage) {
return 0;
}
-int Editor::DelWordOrLine(unsigned int iMessage) {
- // Virtual space may be realised for SCI_DELWORDRIGHT or SCI_DELWORDRIGHTEND
+int Editor::DelWordOrLine(Message iMessage) {
+ // Virtual space may be realised for Message::DelWordRight or Message::DelWordRightEnd
// which means 2 actions so wrap in an undo group.
// Rightwards and leftwards deletions differ in treatment of virtual space.
// Clear virtual space for leftwards, realise for rightwards.
- const bool leftwards = (iMessage == SCI_DELWORDLEFT) || (iMessage == SCI_DELLINELEFT);
+ const bool leftwards = (iMessage == Message::DelWordLeft) || (iMessage == Message::DelLineLeft);
if (!additionalSelectionTyping) {
InvalidateWholeSelection();
@@ -3662,31 +3661,33 @@ int Editor::DelWordOrLine(unsigned int iMessage) {
Range rangeDelete;
switch (iMessage) {
- case SCI_DELWORDLEFT:
+ case Message::DelWordLeft:
rangeDelete = Range(
pdoc->NextWordStart(sel.Range(r).caret.Position(), -1),
sel.Range(r).caret.Position());
break;
- case SCI_DELWORDRIGHT:
+ case Message::DelWordRight:
rangeDelete = Range(
sel.Range(r).caret.Position(),
pdoc->NextWordStart(sel.Range(r).caret.Position(), 1));
break;
- case SCI_DELWORDRIGHTEND:
+ case Message::DelWordRightEnd:
rangeDelete = Range(
sel.Range(r).caret.Position(),
pdoc->NextWordEnd(sel.Range(r).caret.Position(), 1));
break;
- case SCI_DELLINELEFT:
+ case Message::DelLineLeft:
rangeDelete = Range(
pdoc->LineStart(pdoc->LineFromPosition(sel.Range(r).caret.Position())),
sel.Range(r).caret.Position());
break;
- case SCI_DELLINERIGHT:
+ case Message::DelLineRight:
rangeDelete = Range(
sel.Range(r).caret.Position(),
pdoc->LineEnd(pdoc->LineFromPosition(sel.Range(r).caret.Position())));
break;
+ default:
+ break;
}
if (!RangeContainsProtected(rangeDelete.start, rangeDelete.end)) {
pdoc->DeleteChars(rangeDelete.start, rangeDelete.end - rangeDelete.start);
@@ -3705,141 +3706,141 @@ int Editor::DelWordOrLine(unsigned int iMessage) {
return 0;
}
-int Editor::KeyCommand(unsigned int iMessage) {
+int Editor::KeyCommand(Message iMessage) {
switch (iMessage) {
- case SCI_LINEDOWN:
+ case Message::LineDown:
CursorUpOrDown(1, Selection::SelTypes::none);
break;
- case SCI_LINEDOWNEXTEND:
+ case Message::LineDownExtend:
CursorUpOrDown(1, Selection::SelTypes::stream);
break;
- case SCI_LINEDOWNRECTEXTEND:
+ case Message::LineDownRectExtend:
CursorUpOrDown(1, Selection::SelTypes::rectangle);
break;
- case SCI_PARADOWN:
+ case Message::ParaDown:
ParaUpOrDown(1, Selection::SelTypes::none);
break;
- case SCI_PARADOWNEXTEND:
+ case Message::ParaDownExtend:
ParaUpOrDown(1, Selection::SelTypes::stream);
break;
- case SCI_LINESCROLLDOWN:
+ case Message::LineScrollDown:
ScrollTo(topLine + 1);
MoveCaretInsideView(false);
break;
- case SCI_LINEUP:
+ case Message::LineUp:
CursorUpOrDown(-1, Selection::SelTypes::none);
break;
- case SCI_LINEUPEXTEND:
+ case Message::LineUpExtend:
CursorUpOrDown(-1, Selection::SelTypes::stream);
break;
- case SCI_LINEUPRECTEXTEND:
+ case Message::LineUpRectExtend:
CursorUpOrDown(-1, Selection::SelTypes::rectangle);
break;
- case SCI_PARAUP:
+ case Message::ParaUp:
ParaUpOrDown(-1, Selection::SelTypes::none);
break;
- case SCI_PARAUPEXTEND:
+ case Message::ParaUpExtend:
ParaUpOrDown(-1, Selection::SelTypes::stream);
break;
- case SCI_LINESCROLLUP:
+ case Message::LineScrollUp:
ScrollTo(topLine - 1);
MoveCaretInsideView(false);
break;
- case SCI_CHARLEFT:
- case SCI_CHARLEFTEXTEND:
- case SCI_CHARLEFTRECTEXTEND:
- case SCI_CHARRIGHT:
- case SCI_CHARRIGHTEXTEND:
- case SCI_CHARRIGHTRECTEXTEND:
- case SCI_WORDLEFT:
- case SCI_WORDLEFTEXTEND:
- case SCI_WORDRIGHT:
- case SCI_WORDRIGHTEXTEND:
- case SCI_WORDLEFTEND:
- case SCI_WORDLEFTENDEXTEND:
- case SCI_WORDRIGHTEND:
- case SCI_WORDRIGHTENDEXTEND:
- case SCI_WORDPARTLEFT:
- case SCI_WORDPARTLEFTEXTEND:
- case SCI_WORDPARTRIGHT:
- case SCI_WORDPARTRIGHTEXTEND:
- case SCI_HOME:
- case SCI_HOMEEXTEND:
- case SCI_HOMERECTEXTEND:
- case SCI_HOMEDISPLAY:
- case SCI_HOMEDISPLAYEXTEND:
- case SCI_HOMEWRAP:
- case SCI_HOMEWRAPEXTEND:
- case SCI_VCHOME:
- case SCI_VCHOMEEXTEND:
- case SCI_VCHOMERECTEXTEND:
- case SCI_VCHOMEDISPLAY:
- case SCI_VCHOMEDISPLAYEXTEND:
- case SCI_VCHOMEWRAP:
- case SCI_VCHOMEWRAPEXTEND:
- case SCI_LINEEND:
- case SCI_LINEENDEXTEND:
- case SCI_LINEENDRECTEXTEND:
- case SCI_LINEENDDISPLAY:
- case SCI_LINEENDDISPLAYEXTEND:
- case SCI_LINEENDWRAP:
- case SCI_LINEENDWRAPEXTEND:
+ case Message::CharLeft:
+ case Message::CharLeftExtend:
+ case Message::CharLeftRectExtend:
+ case Message::CharRight:
+ case Message::CharRightExtend:
+ case Message::CharRightRectExtend:
+ case Message::WordLeft:
+ case Message::WordLeftExtend:
+ case Message::WordRight:
+ case Message::WordRightExtend:
+ case Message::WordLeftEnd:
+ case Message::WordLeftEndExtend:
+ case Message::WordRightEnd:
+ case Message::WordRightEndExtend:
+ case Message::WordPartLeft:
+ case Message::WordPartLeftExtend:
+ case Message::WordPartRight:
+ case Message::WordPartRightExtend:
+ case Message::Home:
+ case Message::HomeExtend:
+ case Message::HomeRectExtend:
+ case Message::HomeDisplay:
+ case Message::HomeDisplayExtend:
+ case Message::HomeWrap:
+ case Message::HomeWrapExtend:
+ case Message::VCHome:
+ case Message::VCHomeExtend:
+ case Message::VCHomeRectExtend:
+ case Message::VCHomeDisplay:
+ case Message::VCHomeDisplayExtend:
+ case Message::VCHomeWrap:
+ case Message::VCHomeWrapExtend:
+ case Message::LineEnd:
+ case Message::LineEndExtend:
+ case Message::LineEndRectExtend:
+ case Message::LineEndDisplay:
+ case Message::LineEndDisplayExtend:
+ case Message::LineEndWrap:
+ case Message::LineEndWrapExtend:
return HorizontalMove(iMessage);
- case SCI_DOCUMENTSTART:
+ case Message::DocumentStart:
MovePositionTo(0);
SetLastXChosen();
break;
- case SCI_DOCUMENTSTARTEXTEND:
+ case Message::DocumentStartExtend:
MovePositionTo(0, Selection::SelTypes::stream);
SetLastXChosen();
break;
- case SCI_DOCUMENTEND:
+ case Message::DocumentEnd:
MovePositionTo(pdoc->Length());
SetLastXChosen();
break;
- case SCI_DOCUMENTENDEXTEND:
+ case Message::DocumentEndExtend:
MovePositionTo(pdoc->Length(), Selection::SelTypes::stream);
SetLastXChosen();
break;
- case SCI_STUTTEREDPAGEUP:
+ case Message::StutteredPageUp:
PageMove(-1, Selection::SelTypes::none, true);
break;
- case SCI_STUTTEREDPAGEUPEXTEND:
+ case Message::StutteredPageUpExtend:
PageMove(-1, Selection::SelTypes::stream, true);
break;
- case SCI_STUTTEREDPAGEDOWN:
+ case Message::StutteredPageDown:
PageMove(1, Selection::SelTypes::none, true);
break;
- case SCI_STUTTEREDPAGEDOWNEXTEND:
+ case Message::StutteredPageDownExtend:
PageMove(1, Selection::SelTypes::stream, true);
break;
- case SCI_PAGEUP:
+ case Message::PageUp:
PageMove(-1);
break;
- case SCI_PAGEUPEXTEND:
+ case Message::PageUpExtend:
PageMove(-1, Selection::SelTypes::stream);
break;
- case SCI_PAGEUPRECTEXTEND:
+ case Message::PageUpRectExtend:
PageMove(-1, Selection::SelTypes::rectangle);
break;
- case SCI_PAGEDOWN:
+ case Message::PageDown:
PageMove(1);
break;
- case SCI_PAGEDOWNEXTEND:
+ case Message::PageDownExtend:
PageMove(1, Selection::SelTypes::stream);
break;
- case SCI_PAGEDOWNRECTEXTEND:
+ case Message::PageDownRectExtend:
PageMove(1, Selection::SelTypes::rectangle);
break;
- case SCI_EDITTOGGLEOVERTYPE:
+ case Message::EditToggleOvertype:
inOverstrike = !inOverstrike;
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
ShowCaretAtCurrentPosition();
SetIdle(true);
break;
- case SCI_CANCEL: // Cancel any modes - handled in subclass
+ case Message::Cancel: // Cancel any modes - handled in subclass
// Also unselect text
CancelModes();
if ((sel.Count() > 1) && !sel.IsRectangular()) {
@@ -3848,50 +3849,50 @@ int Editor::KeyCommand(unsigned int iMessage) {
sel.DropAdditionalRanges();
}
break;
- case SCI_DELETEBACK:
+ case Message::DeleteBack:
DelCharBack(true);
- if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
+ if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
break;
- case SCI_DELETEBACKNOTLINE:
+ case Message::DeleteBackNotLine:
DelCharBack(false);
- if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
+ if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
break;
- case SCI_TAB:
+ case Message::Tab:
Indent(true);
- if (caretSticky == SC_CARETSTICKY_OFF) {
+ if (caretSticky == CaretSticky::Off) {
SetLastXChosen();
}
EnsureCaretVisible();
ShowCaretAtCurrentPosition(); // Avoid blinking
break;
- case SCI_BACKTAB:
+ case Message::BackTab:
Indent(false);
- if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
+ if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
ShowCaretAtCurrentPosition(); // Avoid blinking
break;
- case SCI_NEWLINE:
+ case Message::NewLine:
NewLine();
break;
- case SCI_FORMFEED:
+ case Message::FormFeed:
AddChar('\f');
break;
- case SCI_ZOOMIN:
+ case Message::ZoomIn:
if (vs.zoomLevel < 20) {
vs.zoomLevel++;
InvalidateStyleRedraw();
NotifyZoom();
}
break;
- case SCI_ZOOMOUT:
+ case Message::ZoomOut:
if (vs.zoomLevel > -10) {
vs.zoomLevel--;
InvalidateStyleRedraw();
@@ -3899,21 +3900,21 @@ int Editor::KeyCommand(unsigned int iMessage) {
}
break;
- case SCI_DELWORDLEFT:
- case SCI_DELWORDRIGHT:
- case SCI_DELWORDRIGHTEND:
- case SCI_DELLINELEFT:
- case SCI_DELLINERIGHT:
+ case Message::DelWordLeft:
+ case Message::DelWordRight:
+ case Message::DelWordRightEnd:
+ case Message::DelLineLeft:
+ case Message::DelLineRight:
return DelWordOrLine(iMessage);
- case SCI_LINECOPY: {
+ case Message::LineCopy: {
const Sci::Line lineStart = pdoc->SciLineFromPosition(SelectionStart().Position());
const Sci::Line lineEnd = pdoc->SciLineFromPosition(SelectionEnd().Position());
CopyRangeToClipboard(pdoc->LineStart(lineStart),
pdoc->LineStart(lineEnd + 1));
}
break;
- case SCI_LINECUT: {
+ case Message::LineCut: {
const Sci::Line lineStart = pdoc->SciLineFromPosition(SelectionStart().Position());
const Sci::Line lineEnd = pdoc->SciLineFromPosition(SelectionEnd().Position());
const Sci::Position start = pdoc->LineStart(lineStart);
@@ -3923,49 +3924,51 @@ int Editor::KeyCommand(unsigned int iMessage) {
SetLastXChosen();
}
break;
- case SCI_LINEDELETE: {
+ case Message::LineDelete: {
const Sci::Line line = pdoc->SciLineFromPosition(sel.MainCaret());
const Sci::Position start = pdoc->LineStart(line);
const Sci::Position end = pdoc->LineStart(line + 1);
pdoc->DeleteChars(start, end - start);
}
break;
- case SCI_LINETRANSPOSE:
+ case Message::LineTranspose:
LineTranspose();
break;
- case SCI_LINEREVERSE:
+ case Message::LineReverse:
LineReverse();
break;
- case SCI_LINEDUPLICATE:
+ case Message::LineDuplicate:
Duplicate(true);
break;
- case SCI_SELECTIONDUPLICATE:
+ case Message::SelectionDuplicate:
Duplicate(false);
break;
- case SCI_LOWERCASE:
+ case Message::LowerCase:
ChangeCaseOfSelection(CaseMapping::lower);
break;
- case SCI_UPPERCASE:
+ case Message::UpperCase:
ChangeCaseOfSelection(CaseMapping::upper);
break;
- case SCI_SCROLLTOSTART:
+ case Message::ScrollToStart:
ScrollTo(0);
break;
- case SCI_SCROLLTOEND:
+ case Message::ScrollToEnd:
ScrollTo(MaxScrollPos());
break;
+ default:
+ break;
}
return 0;
}
-int Editor::KeyDefault(int, int) {
+int Editor::KeyDefault(Keys, KeyMod) {
return 0;
}
-int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) {
+int Editor::KeyDownWithModifiers(Keys key, KeyMod modifiers, bool *consumed) {
DwellEnd(false);
- const unsigned int msg = kmap.Find(key, modifiers);
- if (msg) {
+ const Message msg = kmap.Find(key, modifiers);
+ if (msg != static_cast<Message>(0)) {
if (consumed)
*consumed = true;
return static_cast<int>(WndProc(msg, 0, 0));
@@ -4055,7 +4058,7 @@ void Editor::Indent(bool forwards) {
}
}
}
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
}
class CaseFolderASCII : public CaseFolderTable {
@@ -4076,11 +4079,11 @@ std::unique_ptr<CaseFolder> Editor::CaseFolderForEncoding() {
* @return The position of the found text, -1 if not found.
*/
Sci::Position Editor::FindText(
- uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
- ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
+ uptr_t wParam, ///< Search modes : @c FindOption::MatchCase, @c FindOption::WholeWord,
+ ///< @c FindOption::WordStart, @c FindOption::RegExp or @c FindOption::Posix.
sptr_t lParam) { ///< @c Sci_TextToFind structure: The text to search for in the given range.
- Sci_TextToFind *ft = static_cast<Sci_TextToFind *>(PtrFromSPtr(lParam));
+ TextToFind *ft = static_cast<TextToFind *>(PtrFromSPtr(lParam));
Sci::Position lengthFound = strlen(ft->lpstrText);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
@@ -4089,7 +4092,7 @@ Sci::Position Editor::FindText(
static_cast<Sci::Position>(ft->chrg.cpMin),
static_cast<Sci::Position>(ft->chrg.cpMax),
ft->lpstrText,
- static_cast<int>(wParam),
+ static_cast<FindOption>(wParam),
&lengthFound);
if (pos != -1) {
ft->chrgText.cpMin = static_cast<Sci_PositionCR>(pos);
@@ -4097,7 +4100,7 @@ Sci::Position Editor::FindText(
}
return pos;
} catch (RegexError &) {
- errorStatus = SC_STATUS_WARN_REGEX;
+ errorStatus = Status::RegEx;
return -1;
}
}
@@ -4123,9 +4126,9 @@ void Editor::SearchAnchor() {
* @return The position of the found text, -1 if not found.
*/
Sci::Position Editor::SearchText(
- unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV.
- uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
- ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
+ Message iMessage, ///< Accepts both @c Message::SearchNext and @c Message::SearchPrev.
+ uptr_t wParam, ///< Search modes : @c FindOption::MatchCase, @c FindOption::WholeWord,
+ ///< @c FindOption::WordStart, @c FindOption::RegExp or @c FindOption::Posix.
sptr_t lParam) { ///< The text to search for.
const char *txt = CharPtrFromSPtr(lParam);
@@ -4134,17 +4137,17 @@ Sci::Position Editor::SearchText(
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
- if (iMessage == SCI_SEARCHNEXT) {
+ if (iMessage == Message::SearchNext) {
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
- static_cast<int>(wParam),
+ static_cast<FindOption>(wParam),
&lengthFound);
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
- static_cast<int>(wParam),
+ static_cast<FindOption>(wParam),
&lengthFound);
}
} catch (RegexError &) {
- errorStatus = SC_STATUS_WARN_REGEX;
+ errorStatus = Status::RegEx;
return Sci::invalidPosition;
}
if (pos != Sci::invalidPosition) {
@@ -4190,7 +4193,7 @@ Sci::Position Editor::SearchInTarget(const char *text, Sci::Position length) {
}
return pos;
} catch (RegexError &) {
- errorStatus = SC_STATUS_WARN_REGEX;
+ errorStatus = Status::RegEx;
return -1;
}
}
@@ -4232,12 +4235,12 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
const Sci::Position end = pdoc->LineEnd(currentLine);
std::string text = RangeText(start, end);
- if (pdoc->eolMode != SC_EOL_LF)
+ if (pdoc->eolMode != EndOfLine::Lf)
text.push_back('\r');
- if (pdoc->eolMode != SC_EOL_CR)
+ if (pdoc->eolMode != EndOfLine::Cr)
text.push_back('\n');
ss->Copy(text, pdoc->dbcsCodePage,
- vs.styles[STYLE_DEFAULT].characterSet, false, true);
+ vs.styles[StyleDefault].characterSet, false, true);
}
} else {
std::string text;
@@ -4247,14 +4250,14 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
for (const SelectionRange &current : rangesInOrder) {
text.append(RangeText(current.Start().Position(), current.End().Position()));
if (sel.selType == Selection::SelTypes::rectangle) {
- if (pdoc->eolMode != SC_EOL_LF)
+ if (pdoc->eolMode != EndOfLine::Lf)
text.push_back('\r');
- if (pdoc->eolMode != SC_EOL_CR)
+ if (pdoc->eolMode != EndOfLine::Cr)
text.push_back('\n');
}
}
ss->Copy(text, pdoc->dbcsCodePage,
- vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::SelTypes::lines);
+ vs.styles[StyleDefault].characterSet, sel.IsRectangular(), sel.selType == Selection::SelTypes::lines);
}
}
@@ -4264,14 +4267,14 @@ void Editor::CopyRangeToClipboard(Sci::Position start, Sci::Position end) {
SelectionText selectedText;
std::string text = RangeText(start, end);
selectedText.Copy(text,
- pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
+ pdoc->dbcsCodePage, vs.styles[StyleDefault].characterSet, false, false);
CopyToClipboard(selectedText);
}
void Editor::CopyText(size_t length, const char *text) {
SelectionText selectedText;
selectedText.Copy(std::string(text, length),
- pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
+ pdoc->dbcsCodePage, vs.styles[StyleDefault].characterSet, false, false);
CopyToClipboard(selectedText);
}
@@ -4282,8 +4285,8 @@ void Editor::SetDragPosition(SelectionPosition newPos) {
}
if (!(posDrag == newPos)) {
const CaretPolicies dragCaretPolicies = {
- CaretPolicy(CARET_SLOP | CARET_STRICT | CARET_EVEN, 50),
- CaretPolicy(CARET_SLOP | CARET_STRICT | CARET_EVEN, 2)
+ CaretPolicySlop(CaretPolicy::Slop | CaretPolicy::Strict | CaretPolicy::Even, 50),
+ CaretPolicySlop(CaretPolicy::Slop | CaretPolicy::Strict | CaretPolicy::Even, 2)
};
MovedCaret(newPos, posDrag, true, dragCaretPolicies);
@@ -4298,7 +4301,7 @@ void Editor::SetDragPosition(SelectionPosition newPos) {
}
void Editor::DisplayCursor(Window::Cursor c) {
- if (cursorMode == SC_CURSORNORMAL)
+ if (cursorMode == CursorShape::Normal)
wMain.SetCursor(c);
else
wMain.SetCursor(static_cast<Window::Cursor>(cursorMode));
@@ -4511,8 +4514,8 @@ void Editor::DwellEnd(bool mouseMoved) {
if (mouseMoved)
ticksToDwell = dwellDelay;
else
- ticksToDwell = SC_TIME_FOREVER;
- if (dwelling && (dwellDelay < SC_TIME_FOREVER)) {
+ ticksToDwell = TimeForever;
+ if (dwelling && (dwellDelay < TimeForever)) {
dwelling = false;
NotifyDwelling(ptMouseLast, dwelling);
}
@@ -4528,18 +4531,18 @@ void Editor::MouseLeave() {
}
}
-static constexpr bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) noexcept {
- return (!rectangular && ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0))
- || (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0));
+static constexpr bool AllowVirtualSpace(VirtualSpace virtualSpaceOptions, bool rectangular) noexcept {
+ return (!rectangular && (FlagSet(virtualSpaceOptions, VirtualSpace::UserAccessible)))
+ || (rectangular && (FlagSet(virtualSpaceOptions, VirtualSpace::RectangularSelection)));
}
-void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) {
+void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) {
SetHoverIndicatorPoint(pt);
//Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop);
ptMouseLast = pt;
- const bool ctrl = (modifiers & SCI_CTRL) != 0;
- const bool shift = (modifiers & SCI_SHIFT) != 0;
- const bool alt = (modifiers & SCI_ALT) != 0;
+ const bool ctrl = FlagSet(modifiers, KeyMod::Ctrl);
+ const bool shift = FlagSet(modifiers, KeyMod::Shift);
+ const bool alt = FlagSet(modifiers, KeyMod::Alt);
SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt));
newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false);
@@ -4578,7 +4581,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
selectionUnit = TextUnit::wholeLine;
} else if (selectionUnit != TextUnit::subLine && selectionUnit != TextUnit::wholeLine) {
// If it is neither, reset selection type to line selection.
- selectionUnit = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? TextUnit::subLine : TextUnit::wholeLine;
+ selectionUnit = (Wrapping() && (FlagSet(marginOptions, MarginOption::SubLineSelect))) ? TextUnit::subLine : TextUnit::wholeLine;
}
} else {
if (selectionUnit == TextUnit::character) {
@@ -4646,7 +4649,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
if (!shift) {
// Single click in margin: select wholeLine or only subLine if word wrap is enabled
lineAnchorPos = newPos.Position();
- selectionUnit = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? TextUnit::subLine : TextUnit::wholeLine;
+ selectionUnit = (Wrapping() && (FlagSet(marginOptions, MarginOption::SubLineSelect))) ? TextUnit::subLine : TextUnit::wholeLine;
LineSelection(lineAnchorPos, lineAnchorPos, selectionUnit == TextUnit::wholeLine);
} else {
// Single shift+click in margin: select from line anchor to clicked line
@@ -4659,7 +4662,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
// Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine.
// This ensures that we continue selecting in the same selection mode.
if (sel.Empty() || (selectionUnit != TextUnit::subLine && selectionUnit != TextUnit::wholeLine))
- selectionUnit = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? TextUnit::subLine : TextUnit::wholeLine;
+ selectionUnit = (Wrapping() && (FlagSet(marginOptions, MarginOption::SubLineSelect))) ? TextUnit::subLine : TextUnit::wholeLine;
LineSelection(newPos.Position(), lineAnchorPos, selectionUnit == TextUnit::wholeLine);
}
@@ -4714,7 +4717,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
ShowCaretAtCurrentPosition();
}
-void Editor::RightButtonDownWithModifiers(Point pt, unsigned int, int modifiers) {
+void Editor::RightButtonDownWithModifiers(Point pt, unsigned int, KeyMod modifiers) {
if (NotifyMarginRightClick(pt, modifiers))
return;
}
@@ -4788,7 +4791,7 @@ Range Editor::GetHotSpotRange() const noexcept {
return hotspot;
}
-void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
+void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, KeyMod modifiers) {
if (ptMouseLast != pt) {
DwellEnd(true);
}
@@ -4812,7 +4815,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
PRectangle rcClient = GetClientRectangle();
const Point ptOrigin = GetVisibleOriginInMain();
rcClient.Move(0, -ptOrigin.y);
- if ((dwellDelay < SC_TIME_FOREVER) && rcClient.Contains(pt)) {
+ if ((dwellDelay < TimeForever) && rcClient.Contains(pt)) {
FineTickerStart(TickReason::dwell, dwellDelay, dwellDelay/10);
}
//Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y);
@@ -4829,7 +4832,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
SetDragPosition(movePos);
} else {
if (selectionUnit == TextUnit::character) {
- if (sel.selType == Selection::SelTypes::stream && (modifiers & SCI_ALT) && mouseSelectionRectangularSwitch) {
+ if (sel.selType == Selection::SelTypes::stream && FlagSet(modifiers, KeyMod::Alt) && mouseSelectionRectangularSwitch) {
sel.selType = Selection::SelTypes::rectangle;
}
if (sel.IsRectangular()) {
@@ -4915,7 +4918,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {
}
}
-void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers) {
+void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) {
//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
SelectionPosition newPos = SPositionFromLocation(pt, false, false,
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
@@ -4932,7 +4935,7 @@ void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers
hotSpotClickPos = Sci::invalidPosition;
SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false);
newCharPos = MovePositionOutsideChar(newCharPos, -1);
- NotifyHotSpotReleaseClick(newCharPos.Position(), modifiers & SCI_CTRL);
+ NotifyHotSpotReleaseClick(newCharPos.Position(), modifiers & KeyMod::Ctrl);
}
if (HaveMouseCapture()) {
if (PointInSelMargin(pt)) {
@@ -4951,7 +4954,7 @@ void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers
if (selStart < selEnd) {
if (drag.Length()) {
const Sci::Position length = drag.Length();
- if (modifiers & SCI_CTRL) {
+ if (FlagSet(modifiers, KeyMod::Ctrl)) {
const Sci::Position lengthInserted = pdoc->InsertString(
newPos.Position(), drag.Data(), length);
if (lengthInserted > 0) {
@@ -5014,7 +5017,7 @@ bool Editor::Idle() {
// No more wrapping
needWrap = wrapPending.NeedsWrap();
} else if (needIdleStyling) {
- IdleStyling();
+ IdleStyle();
}
// Add more idle things to do here, but make sure idleDone is
@@ -5037,7 +5040,7 @@ void Editor::TickFor(TickReason reason) {
break;
case TickReason::scroll:
// Auto scroll
- ButtonMoveWithModifiers(ptMouseLast, 0, 0);
+ ButtonMoveWithModifiers(ptMouseLast, 0, KeyMod::Norm);
break;
case TickReason::widen:
SetScrollBars();
@@ -5142,7 +5145,7 @@ Sci::Position Editor::PositionAfterMaxStyling(Sci::Position posMax, bool scrolli
}
void Editor::StartIdleStyling(bool truncatedLastStyling) {
- if ((idleStyling == SC_IDLESTYLING_ALL) || (idleStyling == SC_IDLESTYLING_AFTERVISIBLE)) {
+ if ((idleStyling == IdleStyling::All) || (idleStyling == IdleStyling::AfterVisible)) {
if (pdoc->GetEndStyled() < pdoc->Length()) {
// Style remainder of document in idle time
needIdleStyling = true;
@@ -5171,9 +5174,9 @@ void Editor::StyleAreaBounded(PRectangle rcArea, bool scrolling) {
StartIdleStyling(posAfterMax < posAfterArea);
}
-void Editor::IdleStyling() {
+void Editor::IdleStyle() {
const Sci::Position posAfterArea = PositionAfterArea(GetClientRectangle());
- const Sci::Position endGoal = (idleStyling >= SC_IDLESTYLING_AFTERVISIBLE) ?
+ const Sci::Position endGoal = (idleStyling >= IdleStyling::AfterVisible) ?
pdoc->Length() : posAfterArea;
const Sci::Position posAfterMax = PositionAfterMaxStyling(endGoal, false);
pdoc->StyleToAdjustingLineDuration(posAfterMax);
@@ -5196,9 +5199,9 @@ void Editor::QueueIdleWork(WorkItems items, Sci::Position upTo) {
workNeeded.Need(items, upTo);
}
-int Editor::SupportsFeature(int feature) {
+int Editor::SupportsFeature(Supports feature) {
AutoSurface surface(this);
- return surface->Supports(feature);
+ return surface->SupportsFeature(feature);
}
bool Editor::PaintContains(PRectangle rc) {
@@ -5262,7 +5265,7 @@ void Editor::SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int match
}
void Editor::SetAnnotationHeights(Sci::Line start, Sci::Line end) {
- if (vs.annotationVisible) {
+ if (vs.annotationVisible != AnnotationVisible::Hidden) {
RefreshStyleData();
bool changedHeight = false;
for (Sci::Line line=start; line<end && line<pdoc->LinesTotal(); line++) {
@@ -5289,7 +5292,7 @@ void Editor::SetDocPointer(Document *document) {
pdoc->RemoveWatcher(this, nullptr);
pdoc->Release();
if (!document) {
- pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);
+ pdoc = new Document(DocumentOption::Default);
} else {
pdoc = document;
}
@@ -5324,12 +5327,12 @@ void Editor::SetDocPointer(Document *document) {
Redraw();
}
-void Editor::SetAnnotationVisible(int visible) {
+void Editor::SetAnnotationVisible(AnnotationVisible visible) {
if (vs.annotationVisible != visible) {
- const bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0));
+ const bool changedFromOrToHidden = ((vs.annotationVisible != AnnotationVisible::Hidden) != (visible != AnnotationVisible::Hidden));
vs.annotationVisible = visible;
if (changedFromOrToHidden) {
- const int dir = vs.annotationVisible ? 1 : -1;
+ const int dir = (vs.annotationVisible!= AnnotationVisible::Hidden) ? 1 : -1;
for (Sci::Line line=0; line<pdoc->LinesTotal(); line++) {
const int annotationLines = pdoc->AnnotationLines(line);
if (annotationLines > 0) {
@@ -5342,7 +5345,7 @@ void Editor::SetAnnotationVisible(int visible) {
}
}
-void Editor::SetEOLAnnotationVisible(int visible) {
+void Editor::SetEOLAnnotationVisible(EOLAnnotationVisible visible) {
if (vs.eolAnnotationVisible != visible) {
vs.eolAnnotationVisible = visible;
Redraw();
@@ -5357,7 +5360,7 @@ Sci::Line Editor::ExpandLine(Sci::Line line) {
line++;
while (line <= lineMaxSubord) {
pcs->SetVisible(line, line, true);
- const int level = pdoc->GetLevel(line);
+ const FoldLevel level = pdoc->GetFoldLevel(line);
if (LevelIsHeader(level)) {
if (pcs->GetExpanded(line)) {
line = ExpandLine(line);
@@ -5376,18 +5379,18 @@ void Editor::SetFoldExpanded(Sci::Line lineDoc, bool expanded) {
}
}
-void Editor::FoldLine(Sci::Line line, int action) {
+void Editor::FoldLine(Sci::Line line, FoldAction action) {
if (line >= 0) {
- if (action == SC_FOLDACTION_TOGGLE) {
- if (!LevelIsHeader(pdoc->GetLevel(line))) {
+ if (action == FoldAction::Toggle) {
+ if (!LevelIsHeader(pdoc->GetFoldLevel(line))) {
line = pdoc->GetFoldParent(line);
if (line < 0)
return;
}
- action = (pcs->GetExpanded(line)) ? SC_FOLDACTION_CONTRACT : SC_FOLDACTION_EXPAND;
+ action = (pcs->GetExpanded(line)) ? FoldAction::Contract : FoldAction::Expand;
}
- if (action == SC_FOLDACTION_CONTRACT) {
+ if (action == FoldAction::Contract) {
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
if (lineMaxSubord > line) {
pcs->SetExpanded(line, false);
@@ -5415,23 +5418,23 @@ void Editor::FoldLine(Sci::Line line, int action) {
}
}
-void Editor::FoldExpand(Sci::Line line, int action, int level) {
- bool expanding = action == SC_FOLDACTION_EXPAND;
- if (action == SC_FOLDACTION_TOGGLE) {
+void Editor::FoldExpand(Sci::Line line, FoldAction action, FoldLevel level) {
+ bool expanding = action == FoldAction::Expand;
+ if (action == FoldAction::Toggle) {
expanding = !pcs->GetExpanded(line);
}
// Ensure child lines lexed and fold information extracted before
// flipping the state.
- pdoc->GetLastChild(line, LevelNumber(level));
+ pdoc->GetLastChild(line, LevelNumberPart(level));
SetFoldExpanded(line, expanding);
if (expanding && (pcs->HiddenLines() == 0))
// Nothing to do
return;
- const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, LevelNumber(level));
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, LevelNumberPart(level));
line++;
pcs->SetVisible(line, lineMaxSubord, expanding);
while (line <= lineMaxSubord) {
- const int levelLine = pdoc->GetLevel(line);
+ const FoldLevel levelLine = pdoc->GetFoldLevel(line);
if (LevelIsHeader(levelLine)) {
SetFoldExpanded(line, expanding);
}
@@ -5443,7 +5446,7 @@ void Editor::FoldExpand(Sci::Line line, int action, int level) {
Sci::Line Editor::ContractedFoldNext(Sci::Line lineStart) const {
for (Sci::Line line = lineStart; line<pdoc->LinesTotal();) {
- if (!pcs->GetExpanded(line) && LevelIsHeader(pdoc->GetLevel(line)))
+ if (!pcs->GetExpanded(line) && LevelIsHeader(pdoc->GetFoldLevel(line)))
return line;
line = pcs->ContractedNext(line+1);
if (line < 0)
@@ -5469,9 +5472,9 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
if (!pcs->GetVisible(lineDoc)) {
// Back up to find a non-blank line
Sci::Line lookLine = lineDoc;
- int lookLineLevel = pdoc->GetLevel(lookLine);
+ FoldLevel lookLineLevel = pdoc->GetFoldLevel(lookLine);
while ((lookLine > 0) && LevelIsWhitespace(lookLineLevel)) {
- lookLineLevel = pdoc->GetLevel(--lookLine);
+ lookLineLevel = pdoc->GetFoldLevel(--lookLine);
}
Sci::Line lineParent = pdoc->GetFoldParent(lookLine);
if (lineParent < 0) {
@@ -5491,19 +5494,19 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
}
if (enforcePolicy) {
const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc);
- if (visiblePolicy.policy & VISIBLE_SLOP) {
- if ((topLine > lineDisplay) || ((visiblePolicy.policy & VISIBLE_STRICT) && (topLine + visiblePolicy.slop > lineDisplay))) {
+ if (FlagSet(visiblePolicy.policy, VisiblePolicy::Slop)) {
+ if ((topLine > lineDisplay) || ((FlagSet(visiblePolicy.policy, VisiblePolicy::Strict)) && (topLine + visiblePolicy.slop > lineDisplay))) {
SetTopLine(std::clamp<Sci::Line>(lineDisplay - visiblePolicy.slop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||
- ((visiblePolicy.policy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visiblePolicy.slop))) {
+ ((FlagSet(visiblePolicy.policy, VisiblePolicy::Strict)) && (lineDisplay > topLine + LinesOnScreen() - 1 - visiblePolicy.slop))) {
SetTopLine(std::clamp<Sci::Line>(lineDisplay - LinesOnScreen() + 1 + visiblePolicy.slop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
} else {
- if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy.policy & VISIBLE_STRICT)) {
+ if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (FlagSet(visiblePolicy.policy, VisiblePolicy::Strict))) {
SetTopLine(std::clamp<Sci::Line>(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
@@ -5512,14 +5515,14 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
}
}
-void Editor::FoldAll(int action) {
+void Editor::FoldAll(FoldAction action) {
pdoc->EnsureStyledTo(pdoc->Length());
const Sci::Line maxLine = pdoc->LinesTotal();
- bool expanding = action == SC_FOLDACTION_EXPAND;
- if (action == SC_FOLDACTION_TOGGLE) {
+ bool expanding = action == FoldAction::Expand;
+ if (action == FoldAction::Toggle) {
// Discover current state
for (int lineSeek = 0; lineSeek < maxLine; lineSeek++) {
- if (LevelIsHeader(pdoc->GetLevel(lineSeek))) {
+ if (LevelIsHeader(pdoc->GetFoldLevel(lineSeek))) {
expanding = !pcs->GetExpanded(lineSeek);
break;
}
@@ -5528,18 +5531,18 @@ void Editor::FoldAll(int action) {
if (expanding) {
pcs->SetVisible(0, maxLine-1, true);
for (int line = 0; line < maxLine; line++) {
- const int levelLine = pdoc->GetLevel(line);
+ const FoldLevel levelLine = pdoc->GetFoldLevel(line);
if (LevelIsHeader(levelLine)) {
SetFoldExpanded(line, true);
}
}
} else {
for (Sci::Line line = 0; line < maxLine; line++) {
- const int level = pdoc->GetLevel(line);
+ const FoldLevel level = pdoc->GetFoldLevel(line);
if (LevelIsHeader(level) &&
- (SC_FOLDLEVELBASE == LevelNumber(level))) {
+ (FoldLevel::Base == LevelNumberPart(level))) {
SetFoldExpanded(line, false);
- const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, -1);
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
if (lineMaxSubord > line) {
pcs->SetVisible(line + 1, lineMaxSubord, false);
}
@@ -5550,22 +5553,22 @@ void Editor::FoldAll(int action) {
Redraw();
}
-void Editor::FoldChanged(Sci::Line line, int levelNow, int levelPrev) {
+void Editor::FoldChanged(Sci::Line line, FoldLevel levelNow, FoldLevel levelPrev) {
if (LevelIsHeader(levelNow)) {
if (!LevelIsHeader(levelPrev)) {
// Adding a fold point.
if (pcs->SetExpanded(line, true)) {
RedrawSelMargin();
}
- FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
+ FoldExpand(line, FoldAction::Expand, levelPrev);
}
} else if (LevelIsHeader(levelPrev)) {
const Sci::Line prevLine = line - 1;
- const int prevLineLevel = pdoc->GetLevel(prevLine);
+ const FoldLevel prevLineLevel = pdoc->GetFoldLevel(prevLine);
// Combining two blocks where the first block is collapsed (e.g. by deleting the line(s) which separate(s) the two blocks)
if ((LevelNumber(prevLineLevel) == LevelNumber(levelNow)) && !pcs->GetVisible(prevLine))
- FoldLine(pdoc->GetFoldParent(prevLine), SC_FOLDACTION_EXPAND);
+ FoldLine(pdoc->GetFoldParent(prevLine), FoldAction::Expand);
if (!pcs->GetExpanded(line)) {
// Removing the fold from one that has been contracted so should expand
@@ -5574,7 +5577,7 @@ void Editor::FoldChanged(Sci::Line line, int levelNow, int levelPrev) {
RedrawSelMargin();
}
// Combining two blocks where the second one is collapsed (e.g. by adding characters in the line which separates the two blocks)
- FoldExpand(line, SC_FOLDACTION_EXPAND, levelPrev);
+ FoldExpand(line, FoldAction::Expand, levelPrev);
}
}
if (!LevelIsWhitespace(levelNow) &&
@@ -5595,13 +5598,13 @@ void Editor::FoldChanged(Sci::Line line, int levelNow, int levelPrev) {
if (pcs->HiddenLines()) {
const Sci::Line parentLine = pdoc->GetFoldParent(line);
if (!pcs->GetExpanded(parentLine) && pcs->GetVisible(line))
- FoldLine(parentLine, SC_FOLDACTION_EXPAND);
+ FoldLine(parentLine, FoldAction::Expand);
}
}
}
void Editor::NeedShown(Sci::Position pos, Sci::Position len) {
- if (foldAutomatic & SC_AUTOMATICFOLD_SHOW) {
+ if (FlagSet(foldAutomatic, AutomaticFold::Show)) {
const Sci::Line lineStart = pdoc->SciLineFromPosition(pos);
const Sci::Line lineEnd = pdoc->SciLineFromPosition(pos+len);
for (Sci::Line line = lineStart; line <= lineEnd; line++) {
@@ -5658,7 +5661,7 @@ Sci::Position Editor::ReplaceTarget(bool replacePatterns, const char *text, Sci:
}
bool Editor::IsUnicodeMode() const noexcept {
- return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage);
+ return pdoc && (CpUtf8 == pdoc->dbcsCodePage);
}
int Editor::CodePage() const noexcept {
@@ -5701,132 +5704,140 @@ bool Editor::ValidMargin(uptr_t wParam) const noexcept {
return wParam < vs.ms.size();
}
-void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+void Editor::StyleSetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
vs.EnsureStyle(wParam);
switch (iMessage) {
- case SCI_STYLESETFORE:
+ case Message::StyleSetFore:
vs.styles[wParam].fore = ColourRGBA::FromRGB(static_cast<int>(lParam));
break;
- case SCI_STYLESETBACK:
+ case Message::StyleSetBack:
vs.styles[wParam].back = ColourRGBA::FromRGB(static_cast<int>(lParam));
break;
- case SCI_STYLESETBOLD:
- vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL;
+ case Message::StyleSetBold:
+ vs.styles[wParam].weight = lParam != 0 ? FontWeight::Bold : FontWeight::Normal;
break;
- case SCI_STYLESETWEIGHT:
- vs.styles[wParam].weight = static_cast<int>(lParam);
+ case Message::StyleSetWeight:
+ vs.styles[wParam].weight = static_cast<FontWeight>(lParam);
break;
- case SCI_STYLESETITALIC:
+ case Message::StyleSetItalic:
vs.styles[wParam].italic = lParam != 0;
break;
- case SCI_STYLESETEOLFILLED:
+ case Message::StyleSetEOLFilled:
vs.styles[wParam].eolFilled = lParam != 0;
break;
- case SCI_STYLESETSIZE:
- vs.styles[wParam].size = static_cast<int>(lParam * SC_FONT_SIZE_MULTIPLIER);
+ case Message::StyleSetSize:
+ vs.styles[wParam].size = static_cast<int>(lParam * FontSizeMultiplier);
break;
- case SCI_STYLESETSIZEFRACTIONAL:
+ case Message::StyleSetSizeFractional:
vs.styles[wParam].size = static_cast<int>(lParam);
break;
- case SCI_STYLESETFONT:
+ case Message::StyleSetFont:
if (lParam != 0) {
vs.SetStyleFontName(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
}
break;
- case SCI_STYLESETUNDERLINE:
+ case Message::StyleSetUnderline:
vs.styles[wParam].underline = lParam != 0;
break;
- case SCI_STYLESETCASE:
+ case Message::StyleSetCase:
vs.styles[wParam].caseForce = static_cast<Style::CaseForce>(lParam);
break;
- case SCI_STYLESETCHARACTERSET:
- vs.styles[wParam].characterSet = static_cast<int>(lParam);
+ case Message::StyleSetCharacterSet:
+ vs.styles[wParam].characterSet = static_cast<CharacterSet>(lParam);
pdoc->SetCaseFolder(nullptr);
break;
- case SCI_STYLESETVISIBLE:
+ case Message::StyleSetVisible:
vs.styles[wParam].visible = lParam != 0;
break;
- case SCI_STYLESETCHANGEABLE:
+ case Message::StyleSetChangeable:
vs.styles[wParam].changeable = lParam != 0;
break;
- case SCI_STYLESETHOTSPOT:
+ case Message::StyleSetHotSpot:
vs.styles[wParam].hotspot = lParam != 0;
break;
+ default:
+ break;
}
InvalidateStyleRedraw();
}
-sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+sptr_t Editor::StyleGetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
vs.EnsureStyle(wParam);
switch (iMessage) {
- case SCI_STYLEGETFORE:
+ case Message::StyleGetFore:
return vs.styles[wParam].fore.OpaqueRGB();
- case SCI_STYLEGETBACK:
+ case Message::StyleGetBack:
return vs.styles[wParam].back.OpaqueRGB();
- case SCI_STYLEGETBOLD:
- return vs.styles[wParam].weight > SC_WEIGHT_NORMAL;
- case SCI_STYLEGETWEIGHT:
- return vs.styles[wParam].weight;
- case SCI_STYLEGETITALIC:
+ case Message::StyleGetBold:
+ return vs.styles[wParam].weight > FontWeight::Normal;
+ case Message::StyleGetWeight:
+ return static_cast<sptr_t>(vs.styles[wParam].weight);
+ case Message::StyleGetItalic:
return vs.styles[wParam].italic ? 1 : 0;
- case SCI_STYLEGETEOLFILLED:
+ case Message::StyleGetEOLFilled:
return vs.styles[wParam].eolFilled ? 1 : 0;
- case SCI_STYLEGETSIZE:
- return vs.styles[wParam].size / SC_FONT_SIZE_MULTIPLIER;
- case SCI_STYLEGETSIZEFRACTIONAL:
+ case Message::StyleGetSize:
+ return vs.styles[wParam].size / FontSizeMultiplier;
+ case Message::StyleGetSizeFractional:
return vs.styles[wParam].size;
- case SCI_STYLEGETFONT:
+ case Message::StyleGetFont:
return StringResult(lParam, vs.styles[wParam].fontName);
- case SCI_STYLEGETUNDERLINE:
+ case Message::StyleGetUnderline:
return vs.styles[wParam].underline ? 1 : 0;
- case SCI_STYLEGETCASE:
+ case Message::StyleGetCase:
return static_cast<int>(vs.styles[wParam].caseForce);
- case SCI_STYLEGETCHARACTERSET:
- return vs.styles[wParam].characterSet;
- case SCI_STYLEGETVISIBLE:
+ case Message::StyleGetCharacterSet:
+ return static_cast<sptr_t>(vs.styles[wParam].characterSet);
+ case Message::StyleGetVisible:
return vs.styles[wParam].visible ? 1 : 0;
- case SCI_STYLEGETCHANGEABLE:
+ case Message::StyleGetChangeable:
return vs.styles[wParam].changeable ? 1 : 0;
- case SCI_STYLEGETHOTSPOT:
+ case Message::StyleGetHotSpot:
return vs.styles[wParam].hotspot ? 1 : 0;
+ default:
+ break;
}
return 0;
}
-void Editor::SetSelectionNMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+void Editor::SetSelectionNMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
if (wParam >= sel.Count()) {
return;
}
InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position());
switch (iMessage) {
- case SCI_SETSELECTIONNCARET:
+ case Message::SetSelectionNCaret:
sel.Range(wParam).caret.SetPosition(lParam);
break;
- case SCI_SETSELECTIONNANCHOR:
+ case Message::SetSelectionNAnchor:
sel.Range(wParam).anchor.SetPosition(lParam);
break;
- case SCI_SETSELECTIONNCARETVIRTUALSPACE:
+ case Message::SetSelectionNCaretVirtualSpace:
sel.Range(wParam).caret.SetVirtualSpace(lParam);
break;
- case SCI_SETSELECTIONNANCHORVIRTUALSPACE:
+ case Message::SetSelectionNAnchorVirtualSpace:
sel.Range(wParam).anchor.SetVirtualSpace(lParam);
break;
- case SCI_SETSELECTIONNSTART:
+ case Message::SetSelectionNStart:
sel.Range(wParam).anchor.SetPosition(lParam);
break;
- case SCI_SETSELECTIONNEND:
+ case Message::SetSelectionNEnd:
sel.Range(wParam).caret.SetPosition(lParam);
break;
+
+ default:
+ break;
+
}
InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position());
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
}
sptr_t Editor::StringResult(sptr_t lParam, const char *val) noexcept {
@@ -5853,7 +5864,7 @@ sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len)
return val ? len : 0;
}
-sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
//Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam);
// Optional macro recording hook
@@ -5862,7 +5873,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
switch (iMessage) {
- case SCI_GETTEXT: {
+ case Message::GetText: {
if (lParam == 0)
return pdoc->Length() + 1;
if (wParam == 0)
@@ -5874,7 +5885,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return len;
}
- case SCI_SETTEXT: {
+ case Message::SetText: {
if (lParam == 0)
return 0;
UndoGroup ug(pdoc);
@@ -5885,76 +5896,76 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 1;
}
- case SCI_GETTEXTLENGTH:
+ case Message::GetTextLength:
return pdoc->Length();
- case SCI_CUT:
+ case Message::Cut:
Cut();
SetLastXChosen();
break;
- case SCI_COPY:
+ case Message::Copy:
Copy();
break;
- case SCI_COPYALLOWLINE:
+ case Message::CopyAllowLine:
CopyAllowLine();
break;
- case SCI_VERTICALCENTRECARET:
+ case Message::VerticalCentreCaret:
VerticalCentreCaret();
break;
- case SCI_MOVESELECTEDLINESUP:
+ case Message::MoveSelectedLinesUp:
MoveSelectedLinesUp();
break;
- case SCI_MOVESELECTEDLINESDOWN:
+ case Message::MoveSelectedLinesDown:
MoveSelectedLinesDown();
break;
- case SCI_COPYRANGE:
+ case Message::CopyRange:
CopyRangeToClipboard(static_cast<Sci::Position>(wParam), lParam);
break;
- case SCI_COPYTEXT:
+ case Message::CopyText:
CopyText(wParam, CharPtrFromSPtr(lParam));
break;
- case SCI_PASTE:
+ case Message::Paste:
Paste();
- if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) {
+ if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
break;
- case SCI_CLEAR:
+ case Message::Clear:
Clear();
SetLastXChosen();
EnsureCaretVisible();
break;
- case SCI_UNDO:
+ case Message::Undo:
Undo();
SetLastXChosen();
break;
- case SCI_CANUNDO:
+ case Message::CanUndo:
return (pdoc->CanUndo() && !pdoc->IsReadOnly()) ? 1 : 0;
- case SCI_EMPTYUNDOBUFFER:
+ case Message::EmptyUndoBuffer:
pdoc->DeleteUndoHistory();
return 0;
- case SCI_GETFIRSTVISIBLELINE:
+ case Message::GetFirstVisibleLine:
return topLine;
- case SCI_SETFIRSTVISIBLELINE:
+ case Message::SetFirstVisibleLine:
ScrollTo(static_cast<Sci::Line>(wParam));
break;
- case SCI_GETLINE: { // Risk of overwriting the end of the buffer
+ case Message::GetLine: { // Risk of overwriting the end of the buffer
const Sci::Position lineStart =
pdoc->LineStart(static_cast<Sci::Line>(wParam));
const Sci::Position lineEnd =
@@ -5969,16 +5980,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return len;
}
- case SCI_GETLINECOUNT:
+ case Message::GetLineCount:
if (pdoc->LinesTotal() == 0)
return 1;
else
return pdoc->LinesTotal();
- case SCI_GETMODIFY:
+ case Message::GetModify:
return !pdoc->IsSavePoint();
- case SCI_SETSEL: {
+ case Message::SetSel: {
Sci::Position nStart = static_cast<Sci::Position>(wParam);
Sci::Position nEnd = lParam;
if (nEnd < 0)
@@ -5993,7 +6004,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETSELTEXT: {
+ case Message::GetSelText: {
SelectionText selectedText;
CopySelectionRange(&selectedText);
if (lParam == 0) {
@@ -6011,12 +6022,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
}
- case SCI_LINEFROMPOSITION:
+ case Message::LineFromPosition:
if (static_cast<Sci::Position>(wParam) < 0)
return 0;
return pdoc->LineFromPosition(static_cast<Sci::Position>(wParam));
- case SCI_POSITIONFROMLINE:
+ case Message::PositionFromLine:
if (static_cast<Sci::Position>(wParam) < 0)
wParam = pdoc->LineFromPosition(SelectionStart().Position());
if (wParam == 0)
@@ -6028,13 +6039,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->LineStart(static_cast<Sci::Position>(wParam));
// Replacement of the old Scintilla interpretation of EM_LINELENGTH
- case SCI_LINELENGTH:
+ case Message::LineLength:
if ((static_cast<Sci::Position>(wParam) < 0) ||
(static_cast<Sci::Position>(wParam) > pdoc->LineFromPosition(pdoc->Length())))
return 0;
return pdoc->LineStart(static_cast<Sci::Position>(wParam) + 1) - pdoc->LineStart(static_cast<Sci::Position>(wParam));
- case SCI_REPLACESEL: {
+ case Message::ReplaceSel: {
if (lParam == 0)
return 0;
UndoGroup ug(pdoc);
@@ -6048,126 +6059,126 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_SETTARGETSTART:
+ case Message::SetTargetStart:
targetRange.start.SetPosition(static_cast<Sci::Position>(wParam));
break;
- case SCI_GETTARGETSTART:
+ case Message::GetTargetStart:
return targetRange.start.Position();
- case SCI_SETTARGETSTARTVIRTUALSPACE:
+ case Message::SetTargetStartVirtualSpace:
targetRange.start.SetVirtualSpace(static_cast<Sci::Position>(wParam));
break;
- case SCI_GETTARGETSTARTVIRTUALSPACE:
+ case Message::GetTargetStartVirtualSpace:
return targetRange.start.VirtualSpace();
- case SCI_SETTARGETEND:
+ case Message::SetTargetEnd:
targetRange.end.SetPosition(static_cast<Sci::Position>(wParam));
break;
- case SCI_GETTARGETEND:
+ case Message::GetTargetEnd:
return targetRange.end.Position();
- case SCI_SETTARGETENDVIRTUALSPACE:
+ case Message::SetTargetEndVirtualSpace:
targetRange.end.SetVirtualSpace(static_cast<Sci::Position>(wParam));
break;
- case SCI_GETTARGETENDVIRTUALSPACE:
+ case Message::GetTargetEndVirtualSpace:
return targetRange.end.VirtualSpace();
- case SCI_SETTARGETRANGE:
+ case Message::SetTargetRange:
targetRange.start.SetPosition(static_cast<Sci::Position>(wParam));
targetRange.end.SetPosition(lParam);
break;
- case SCI_TARGETWHOLEDOCUMENT:
+ case Message::TargetWholeDocument:
targetRange.start.SetPosition(0);
targetRange.end.SetPosition(pdoc->Length());
break;
- case SCI_TARGETFROMSELECTION:
+ case Message::TargetFromSelection:
targetRange.start = sel.RangeMain().Start();
targetRange.end = sel.RangeMain().End();
break;
- case SCI_GETTARGETTEXT: {
+ case Message::GetTargetText: {
std::string text = RangeText(targetRange.start.Position(), targetRange.end.Position());
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(text.c_str()), text.length());
}
- case SCI_REPLACETARGET:
+ case Message::ReplaceTarget:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
- case SCI_REPLACETARGETRE:
+ case Message::ReplaceTargetRE:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
- case SCI_SEARCHINTARGET:
+ case Message::SearchInTarget:
PLATFORM_ASSERT(lParam);
return SearchInTarget(CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
- case SCI_SETSEARCHFLAGS:
- searchFlags = static_cast<int>(wParam);
+ case Message::SetSearchFlags:
+ searchFlags = static_cast<FindOption>(wParam);
break;
- case SCI_GETSEARCHFLAGS:
- return searchFlags;
+ case Message::GetSearchFlags:
+ return static_cast<sptr_t>(searchFlags);
- case SCI_GETTAG:
+ case Message::GetTag:
return GetTag(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
- case SCI_POSITIONBEFORE:
+ case Message::PositionBefore:
return pdoc->MovePositionOutsideChar(static_cast<Sci::Position>(wParam) - 1, -1, true);
- case SCI_POSITIONAFTER:
+ case Message::PositionAfter:
return pdoc->MovePositionOutsideChar(static_cast<Sci::Position>(wParam) + 1, 1, true);
- case SCI_POSITIONRELATIVE:
+ case Message::PositionRelative:
return std::clamp<Sci::Position>(pdoc->GetRelativePosition(
static_cast<Sci::Position>(wParam), lParam),
0, pdoc->Length());
- case SCI_POSITIONRELATIVECODEUNITS:
+ case Message::PositionRelativeCodeUnits:
return std::clamp<Sci::Position>(pdoc->GetRelativePositionUTF16(
static_cast<Sci::Position>(wParam), lParam),
0, pdoc->Length());
- case SCI_LINESCROLL:
+ case Message::LineScroll:
ScrollTo(topLine + static_cast<Sci::Line>(lParam));
HorizontalScrollTo(xOffset + static_cast<int>(wParam) * static_cast<int>(vs.spaceWidth));
return 1;
- case SCI_SETXOFFSET:
+ case Message::SetXOffset:
xOffset = static_cast<int>(wParam);
- ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
+ ContainerNeedsUpdate(Update::HScroll);
SetHorizontalScrollPos();
Redraw();
break;
- case SCI_GETXOFFSET:
+ case Message::GetXOffset:
return xOffset;
- case SCI_CHOOSECARETX:
+ case Message::ChooseCaretX:
SetLastXChosen();
break;
- case SCI_SCROLLCARET:
+ case Message::ScrollCaret:
EnsureCaretVisible();
break;
- case SCI_SETREADONLY:
+ case Message::SetReadOnly:
pdoc->SetReadOnly(wParam != 0);
return 1;
- case SCI_GETREADONLY:
+ case Message::GetReadOnly:
return pdoc->IsReadOnly();
- case SCI_CANPASTE:
+ case Message::CanPaste:
return CanPaste();
- case SCI_POINTXFROMPOSITION:
+ case Message::PointXFromPosition:
if (lParam < 0) {
return 0;
} else {
@@ -6176,7 +6187,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return static_cast<int>(pt.x) - vs.textStart + vs.fixedColumnWidth;
}
- case SCI_POINTYFROMPOSITION:
+ case Message::PointYFromPosition:
if (lParam < 0) {
return 0;
} else {
@@ -6184,13 +6195,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return static_cast<int>(pt.y);
}
- case SCI_FINDTEXT:
+ case Message::FindText:
return FindText(wParam, lParam);
- case SCI_GETTEXTRANGE: {
+ case Message::GetTextRange: {
if (lParam == 0)
return 0;
- Sci_TextRange *tr = static_cast<Sci_TextRange *>(PtrFromSPtr(lParam));
+ TextRange *tr = static_cast<TextRange *>(PtrFromSPtr(lParam));
Sci::Position cpMax = static_cast<Sci::Position>(tr->chrg.cpMax);
if (cpMax == -1)
cpMax = pdoc->Length();
@@ -6202,34 +6213,34 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return len; // Not including NUL
}
- case SCI_HIDESELECTION:
+ case Message::HideSelection:
view.hideSelection = wParam != 0;
Redraw();
break;
- case SCI_FORMATRANGE:
- return FormatRange(wParam != 0, static_cast<Sci_RangeToFormat *>(PtrFromSPtr(lParam)));
+ case Message::FormatRange:
+ return FormatRange(wParam != 0, static_cast<RangeToFormat *>(PtrFromSPtr(lParam)));
- case SCI_GETMARGINLEFT:
+ case Message::GetMarginLeft:
return vs.leftMarginWidth;
- case SCI_GETMARGINRIGHT:
+ case Message::GetMarginRight:
return vs.rightMarginWidth;
- case SCI_SETMARGINLEFT:
+ case Message::SetMarginLeft:
lastXChosen += static_cast<int>(lParam) - vs.leftMarginWidth;
vs.leftMarginWidth = static_cast<int>(lParam);
InvalidateStyleRedraw();
break;
- case SCI_SETMARGINRIGHT:
+ case Message::SetMarginRight:
vs.rightMarginWidth = static_cast<int>(lParam);
InvalidateStyleRedraw();
break;
// Control specific messages
- case SCI_ADDTEXT: {
+ case Message::AddText: {
if (lParam == 0)
return 0;
const Sci::Position lengthInserted = pdoc->InsertString(
@@ -6238,12 +6249,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 0;
}
- case SCI_ADDSTYLEDTEXT:
+ case Message::AddStyledText:
if (lParam)
AddStyledText(CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
return 0;
- case SCI_INSERTTEXT: {
+ case Message::InsertText: {
if (lParam == 0)
return 0;
Sci::Position insertPos = static_cast<Sci::Position>(wParam);
@@ -6258,54 +6269,54 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 0;
}
- case SCI_CHANGEINSERTION:
+ case Message::ChangeInsertion:
PLATFORM_ASSERT(lParam);
pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
return 0;
- case SCI_APPENDTEXT:
+ case Message::AppendText:
pdoc->InsertString(pdoc->Length(),
CharPtrFromSPtr(lParam), static_cast<Sci::Position>(wParam));
return 0;
- case SCI_CLEARALL:
+ case Message::ClearAll:
ClearAll();
return 0;
- case SCI_DELETERANGE:
+ case Message::DeleteRange:
pdoc->DeleteChars(static_cast<Sci::Position>(wParam), lParam);
return 0;
- case SCI_CLEARDOCUMENTSTYLE:
+ case Message::ClearDocumentStyle:
ClearDocumentStyle();
return 0;
- case SCI_SETUNDOCOLLECTION:
+ case Message::SetUndoCollection:
pdoc->SetUndoCollection(wParam != 0);
return 0;
- case SCI_GETUNDOCOLLECTION:
+ case Message::GetUndoCollection:
return pdoc->IsCollectingUndo();
- case SCI_BEGINUNDOACTION:
+ case Message::BeginUndoAction:
pdoc->BeginUndoAction();
return 0;
- case SCI_ENDUNDOACTION:
+ case Message::EndUndoAction:
pdoc->EndUndoAction();
return 0;
- case SCI_GETCARETPERIOD:
+ case Message::GetCaretPeriod:
return caret.period;
- case SCI_SETCARETPERIOD:
+ case Message::SetCaretPeriod:
CaretSetPeriod(static_cast<int>(wParam));
break;
- case SCI_GETWORDCHARS:
+ case Message::GetWordChars:
return pdoc->GetCharsOfClass(CharacterClass::word, UCharPtrFromSPtr(lParam));
- case SCI_SETWORDCHARS: {
+ case Message::SetWordChars: {
pdoc->SetDefaultCharClasses(false);
if (lParam == 0)
return 0;
@@ -6313,48 +6324,48 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETWHITESPACECHARS:
+ case Message::GetWhitespaceChars:
return pdoc->GetCharsOfClass(CharacterClass::space, UCharPtrFromSPtr(lParam));
- case SCI_SETWHITESPACECHARS: {
+ case Message::SetWhitespaceChars: {
if (lParam == 0)
return 0;
pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharacterClass::space);
}
break;
- case SCI_GETPUNCTUATIONCHARS:
+ case Message::GetPunctuationChars:
return pdoc->GetCharsOfClass(CharacterClass::punctuation, UCharPtrFromSPtr(lParam));
- case SCI_SETPUNCTUATIONCHARS: {
+ case Message::SetPunctuationChars: {
if (lParam == 0)
return 0;
pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharacterClass::punctuation);
}
break;
- case SCI_SETCHARSDEFAULT:
+ case Message::SetCharsDefault:
pdoc->SetDefaultCharClasses(true);
break;
- case SCI_SETCHARACTERCATEGORYOPTIMIZATION:
+ case Message::SetCharacterCategoryOptimization:
pdoc->SetCharacterCategoryOptimization(static_cast<int>(wParam));
break;
- case SCI_GETCHARACTERCATEGORYOPTIMIZATION:
+ case Message::GetCharacterCategoryOptimization:
return pdoc->CharacterCategoryOptimization();
- case SCI_GETLENGTH:
+ case Message::GetLength:
return pdoc->Length();
- case SCI_ALLOCATE:
+ case Message::Allocate:
pdoc->Allocate(static_cast<Sci::Position>(wParam));
break;
- case SCI_GETCHARAT:
+ case Message::GetCharAt:
return pdoc->CharAt(static_cast<Sci::Position>(wParam));
- case SCI_SETCURRENTPOS:
+ case Message::SetCurrentPos:
if (sel.IsRectangular()) {
sel.Rectangular().caret.SetPosition(static_cast<Sci::Position>(wParam));
SetRectangularRange();
@@ -6364,10 +6375,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETCURRENTPOS:
+ case Message::GetCurrentPos:
return sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret();
- case SCI_SETANCHOR:
+ case Message::SetAnchor:
if (sel.IsRectangular()) {
sel.Rectangular().anchor.SetPosition(static_cast<Sci::Position>(wParam));
SetRectangularRange();
@@ -6377,70 +6388,70 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETANCHOR:
+ case Message::GetAnchor:
return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor();
- case SCI_SETSELECTIONSTART:
+ case Message::SetSelectionStart:
SetSelection(std::max(sel.MainCaret(), static_cast<Sci::Position>(wParam)), static_cast<Sci::Position>(wParam));
break;
- case SCI_GETSELECTIONSTART:
+ case Message::GetSelectionStart:
return sel.LimitsForRectangularElseMain().start.Position();
- case SCI_SETSELECTIONEND:
+ case Message::SetSelectionEnd:
SetSelection(static_cast<Sci::Position>(wParam), std::min(sel.MainAnchor(), static_cast<Sci::Position>(wParam)));
break;
- case SCI_GETSELECTIONEND:
+ case Message::GetSelectionEnd:
return sel.LimitsForRectangularElseMain().end.Position();
- case SCI_SETEMPTYSELECTION:
+ case Message::SetEmptySelection:
SetEmptySelection(static_cast<Sci::Position>(wParam));
break;
- case SCI_SETPRINTMAGNIFICATION:
+ case Message::SetPrintMagnification:
view.printParameters.magnification = static_cast<int>(wParam);
break;
- case SCI_GETPRINTMAGNIFICATION:
+ case Message::GetPrintMagnification:
return view.printParameters.magnification;
- case SCI_SETPRINTCOLOURMODE:
- view.printParameters.colourMode = static_cast<int>(wParam);
+ case Message::SetPrintColourMode:
+ view.printParameters.colourMode = static_cast<PrintOption>(wParam);
break;
- case SCI_GETPRINTCOLOURMODE:
- return view.printParameters.colourMode;
+ case Message::GetPrintColourMode:
+ return static_cast<sptr_t>(view.printParameters.colourMode);
- case SCI_SETPRINTWRAPMODE:
- view.printParameters.wrapState = (wParam == SC_WRAP_WORD) ? WrapMode::word : WrapMode::none;
+ case Message::SetPrintWrapMode:
+ view.printParameters.wrapState = (static_cast<Wrap>(wParam) == Wrap::Word) ? Wrap::Word : Wrap::None;
break;
- case SCI_GETPRINTWRAPMODE:
+ case Message::GetPrintWrapMode:
return static_cast<sptr_t>(view.printParameters.wrapState);
- case SCI_GETSTYLEAT:
+ case Message::GetStyleAt:
if (static_cast<Sci::Position>(wParam) >= pdoc->Length())
return 0;
else
return pdoc->StyleAt(static_cast<Sci::Position>(wParam));
- case SCI_REDO:
+ case Message::Redo:
Redo();
break;
- case SCI_SELECTALL:
+ case Message::SelectAll:
SelectAll();
break;
- case SCI_SETSAVEPOINT:
+ case Message::SetSavePoint:
pdoc->SetSavePoint();
break;
- case SCI_GETSTYLEDTEXT: {
+ case Message::GetStyledText: {
if (lParam == 0)
return 0;
- Sci_TextRange *tr = static_cast<Sci_TextRange *>(PtrFromSPtr(lParam));
+ TextRange *tr = static_cast<TextRange *>(PtrFromSPtr(lParam));
Sci::Position iPlace = 0;
for (Sci::Position iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) {
tr->lpstrText[iPlace++] = pdoc->CharAt(iChar);
@@ -6451,72 +6462,72 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return iPlace;
}
- case SCI_CANREDO:
+ case Message::CanRedo:
return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0;
- case SCI_MARKERLINEFROMHANDLE:
+ case Message::MarkerLineFromHandle:
return pdoc->LineFromHandle(static_cast<int>(wParam));
- case SCI_MARKERDELETEHANDLE:
+ case Message::MarkerDeleteHandle:
pdoc->DeleteMarkFromHandle(static_cast<int>(wParam));
break;
- case SCI_MARKERHANDLEFROMLINE:
+ case Message::MarkerHandleFromLine:
return pdoc->MarkerHandleFromLine(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
- case SCI_MARKERNUMBERFROMLINE:
+ case Message::MarkerNumberFromLine:
return pdoc->MarkerNumberFromLine(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
- case SCI_GETVIEWWS:
+ case Message::GetViewWS:
return static_cast<sptr_t>(vs.viewWhitespace);
- case SCI_SETVIEWWS:
+ case Message::SetViewWS:
vs.viewWhitespace = static_cast<WhiteSpace>(wParam);
Redraw();
break;
- case SCI_GETTABDRAWMODE:
+ case Message::GetTabDrawMode:
return static_cast<sptr_t>(vs.tabDrawMode);
- case SCI_SETTABDRAWMODE:
+ case Message::SetTabDrawMode:
vs.tabDrawMode = static_cast<TabDrawMode>(wParam);
Redraw();
break;
- case SCI_GETWHITESPACESIZE:
+ case Message::GetWhitespaceSize:
return vs.whitespaceSize;
- case SCI_SETWHITESPACESIZE:
+ case Message::SetWhitespaceSize:
vs.whitespaceSize = static_cast<int>(wParam);
Redraw();
break;
- case SCI_POSITIONFROMPOINT:
+ case Message::PositionFromPoint:
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
false, false);
- case SCI_POSITIONFROMPOINTCLOSE:
+ case Message::PositionFromPointClose:
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
true, false);
- case SCI_CHARPOSITIONFROMPOINT:
+ case Message::CharPositionFromPoint:
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
false, true);
- case SCI_CHARPOSITIONFROMPOINTCLOSE:
+ case Message::CharPositionFromPointClose:
return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)),
true, true);
- case SCI_GOTOLINE:
+ case Message::GotoLine:
GoToLine(static_cast<Sci::Line>(wParam));
break;
- case SCI_GOTOPOS:
+ case Message::GotoPos:
SetEmptySelection(static_cast<Sci::Position>(wParam));
EnsureCaretVisible();
break;
- case SCI_GETCURLINE: {
+ case Message::GetCurLine: {
const Sci::Line lineCurrentPos = pdoc->SciLineFromPosition(sel.MainCaret());
const Sci::Position lineStart = pdoc->LineStart(lineCurrentPos);
const Sci::Position lineEnd = pdoc->LineStart(lineCurrentPos + 1);
@@ -6531,18 +6542,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return sel.MainCaret() - lineStart;
}
- case SCI_GETENDSTYLED:
+ case Message::GetEndStyled:
return pdoc->GetEndStyled();
- case SCI_GETEOLMODE:
- return pdoc->eolMode;
+ case Message::GetEOLMode:
+ return static_cast<sptr_t>(pdoc->eolMode);
- case SCI_SETEOLMODE:
- pdoc->eolMode = static_cast<int>(wParam);
+ case Message::SetEOLMode:
+ pdoc->eolMode = static_cast<EndOfLine>(wParam);
break;
- case SCI_SETLINEENDTYPESALLOWED:
- if (pdoc->SetLineEndTypesAllowed(static_cast<int>(wParam))) {
+ case Message::SetLineEndTypesAllowed:
+ if (pdoc->SetLineEndTypesAllowed(static_cast<LineEndType>(wParam))) {
pcs->Clear();
pcs->InsertLines(0, pdoc->LinesTotal() - 1);
SetAnnotationHeights(0, pdoc->LinesTotal());
@@ -6550,34 +6561,34 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETLINEENDTYPESALLOWED:
- return pdoc->GetLineEndTypesAllowed();
+ case Message::GetLineEndTypesAllowed:
+ return static_cast<sptr_t>(pdoc->GetLineEndTypesAllowed());
- case SCI_GETLINEENDTYPESACTIVE:
- return pdoc->GetLineEndTypesActive();
+ case Message::GetLineEndTypesActive:
+ return static_cast<sptr_t>(pdoc->GetLineEndTypesActive());
- case SCI_STARTSTYLING:
+ case Message::StartStyling:
pdoc->StartStyling(static_cast<Sci::Position>(wParam));
break;
- case SCI_SETSTYLING:
+ case Message::SetStyling:
if (static_cast<Sci::Position>(wParam) < 0)
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
else
pdoc->SetStyleFor(static_cast<Sci::Position>(wParam), static_cast<char>(lParam));
break;
- case SCI_SETSTYLINGEX: // Specify a complete styling buffer
+ case Message::SetStylingEx: // Specify a complete styling buffer
if (lParam == 0)
return 0;
pdoc->SetStyles(static_cast<Sci::Position>(wParam), CharPtrFromSPtr(lParam));
break;
- case SCI_SETBUFFEREDDRAW:
+ case Message::SetBufferedDraw:
view.bufferedDraw = wParam != 0;
break;
- case SCI_GETBUFFEREDDRAW:
+ case Message::GetBufferedDraw:
return view.bufferedDraw;
#ifdef INCLUDE_DEPRECATED_FEATURES
@@ -6590,24 +6601,25 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
#endif
- case SCI_GETPHASESDRAW:
+ case Message::GetPhasesDraw:
return static_cast<sptr_t>(view.phasesDraw);
- case SCI_SETPHASESDRAW:
+ case Message::SetPhasesDraw:
if (view.SetPhasesDraw(static_cast<int>(wParam)))
InvalidateStyleRedraw();
break;
- case SCI_SETFONTQUALITY:
- vs.extraFontFlag &= ~SC_EFF_QUALITY_MASK;
- vs.extraFontFlag |= (wParam & SC_EFF_QUALITY_MASK);
+ case Message::SetFontQuality:
+ vs.extraFontFlag = static_cast<FontQuality>(
+ (static_cast<int>(vs.extraFontFlag) & ~static_cast<int>(FontQuality::QualityMask)) |
+ (wParam & static_cast<int>(FontQuality::QualityMask)));
InvalidateStyleRedraw();
break;
- case SCI_GETFONTQUALITY:
- return (vs.extraFontFlag & SC_EFF_QUALITY_MASK);
+ case Message::GetFontQuality:
+ return FlagSet(vs.extraFontFlag, FontQuality::QualityMask);
- case SCI_SETTABWIDTH:
+ case Message::SetTabWidth:
if (wParam > 0) {
pdoc->tabInChars = static_cast<int>(wParam);
if (pdoc->indentInChars == 0)
@@ -6616,34 +6628,34 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleRedraw();
break;
- case SCI_GETTABWIDTH:
+ case Message::GetTabWidth:
return pdoc->tabInChars;
- case SCI_SETTABMINIMUMWIDTH:
+ case Message::SetTabMinimumWidth:
SetAppearance(view.tabWidthMinimumPixels, static_cast<int>(wParam));
break;
- case SCI_GETTABMINIMUMWIDTH:
+ case Message::GetTabMinimumWidth:
return view.tabWidthMinimumPixels;
- case SCI_CLEARTABSTOPS:
+ case Message::ClearTabStops:
if (view.ClearTabstops(static_cast<Sci::Line>(wParam))) {
- const DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, nullptr, static_cast<Sci::Line>(wParam));
+ const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, static_cast<Sci::Line>(wParam));
NotifyModified(pdoc, mh, nullptr);
}
break;
- case SCI_ADDTABSTOP:
+ case Message::AddTabStop:
if (view.AddTabstop(static_cast<Sci::Line>(wParam), static_cast<int>(lParam))) {
- const DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, nullptr, static_cast<Sci::Line>(wParam));
+ const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, static_cast<Sci::Line>(wParam));
NotifyModified(pdoc, mh, nullptr);
}
break;
- case SCI_GETNEXTTABSTOP:
+ case Message::GetNextTabStop:
return view.GetNextTabstop(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
- case SCI_SETINDENT:
+ case Message::SetIndent:
pdoc->indentInChars = static_cast<int>(wParam);
if (pdoc->indentInChars != 0)
pdoc->actualIndentInChars = pdoc->indentInChars;
@@ -6652,133 +6664,133 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateStyleRedraw();
break;
- case SCI_GETINDENT:
+ case Message::GetIndent:
return pdoc->indentInChars;
- case SCI_SETUSETABS:
+ case Message::SetUseTabs:
pdoc->useTabs = wParam != 0;
InvalidateStyleRedraw();
break;
- case SCI_GETUSETABS:
+ case Message::GetUseTabs:
return pdoc->useTabs;
- case SCI_SETLINEINDENTATION:
+ case Message::SetLineIndentation:
pdoc->SetLineIndentation(static_cast<Sci::Line>(wParam), lParam);
break;
- case SCI_GETLINEINDENTATION:
+ case Message::GetLineIndentation:
return pdoc->GetLineIndentation(static_cast<Sci::Line>(wParam));
- case SCI_GETLINEINDENTPOSITION:
+ case Message::GetLineIndentPosition:
return pdoc->GetLineIndentPosition(static_cast<Sci::Line>(wParam));
- case SCI_SETTABINDENTS:
+ case Message::SetTabIndents:
pdoc->tabIndents = wParam != 0;
break;
- case SCI_GETTABINDENTS:
+ case Message::GetTabIndents:
return pdoc->tabIndents;
- case SCI_SETBACKSPACEUNINDENTS:
+ case Message::SetBackSpaceUnIndents:
pdoc->backspaceUnindents = wParam != 0;
break;
- case SCI_GETBACKSPACEUNINDENTS:
+ case Message::GetBackSpaceUnIndents:
return pdoc->backspaceUnindents;
- case SCI_SETMOUSEDWELLTIME:
+ case Message::SetMouseDwellTime:
dwellDelay = static_cast<int>(wParam);
ticksToDwell = dwellDelay;
break;
- case SCI_GETMOUSEDWELLTIME:
+ case Message::GetMouseDwellTime:
return dwellDelay;
- case SCI_WORDSTARTPOSITION:
+ case Message::WordStartPosition:
return pdoc->ExtendWordSelect(static_cast<Sci::Position>(wParam), -1, lParam != 0);
- case SCI_WORDENDPOSITION:
+ case Message::WordEndPosition:
return pdoc->ExtendWordSelect(static_cast<Sci::Position>(wParam), 1, lParam != 0);
- case SCI_ISRANGEWORD:
+ case Message::IsRangeWord:
return pdoc->IsWordAt(static_cast<Sci::Position>(wParam), lParam);
- case SCI_SETIDLESTYLING:
- idleStyling = static_cast<int>(wParam);
+ case Message::SetIdleStyling:
+ idleStyling = static_cast<IdleStyling>(wParam);
break;
- case SCI_GETIDLESTYLING:
- return idleStyling;
+ case Message::GetIdleStyling:
+ return static_cast<sptr_t>(idleStyling);
- case SCI_SETWRAPMODE:
- if (vs.SetWrapState(static_cast<int>(wParam))) {
+ case Message::SetWrapMode:
+ if (vs.SetWrapState(static_cast<Wrap>(wParam))) {
xOffset = 0;
- ContainerNeedsUpdate(SC_UPDATE_H_SCROLL);
+ ContainerNeedsUpdate(Update::HScroll);
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
- case SCI_GETWRAPMODE:
+ case Message::GetWrapMode:
return static_cast<sptr_t>(vs.wrap.state);
- case SCI_SETWRAPVISUALFLAGS:
- if (vs.SetWrapVisualFlags(static_cast<int>(wParam))) {
+ case Message::SetWrapVisualFlags:
+ if (vs.SetWrapVisualFlags(static_cast<WrapVisualFlag>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
- case SCI_GETWRAPVISUALFLAGS:
- return vs.wrap.visualFlags;
+ case Message::GetWrapVisualFlags:
+ return static_cast<sptr_t>(vs.wrap.visualFlags);
- case SCI_SETWRAPVISUALFLAGSLOCATION:
- if (vs.SetWrapVisualFlagsLocation(static_cast<int>(wParam))) {
+ case Message::SetWrapVisualFlagsLocation:
+ if (vs.SetWrapVisualFlagsLocation(static_cast<WrapVisualLocation>(wParam))) {
InvalidateStyleRedraw();
}
break;
- case SCI_GETWRAPVISUALFLAGSLOCATION:
- return vs.wrap.visualFlagsLocation;
+ case Message::GetWrapVisualFlagsLocation:
+ return static_cast<sptr_t>(vs.wrap.visualFlagsLocation);
- case SCI_SETWRAPSTARTINDENT:
+ case Message::SetWrapStartIndent:
if (vs.SetWrapVisualStartIndent(static_cast<int>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
- case SCI_GETWRAPSTARTINDENT:
+ case Message::GetWrapStartIndent:
return vs.wrap.visualStartIndent;
- case SCI_SETWRAPINDENTMODE:
- if (vs.SetWrapIndentMode(static_cast<int>(wParam))) {
+ case Message::SetWrapIndentMode:
+ if (vs.SetWrapIndentMode(static_cast<WrapIndentMode>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
- case SCI_GETWRAPINDENTMODE:
- return vs.wrap.indentMode;
+ case Message::GetWrapIndentMode:
+ return static_cast<sptr_t>(vs.wrap.indentMode);
- case SCI_SETLAYOUTCACHE:
- if (wParam <= SC_CACHE_DOCUMENT) {
- view.llc.SetLevel(static_cast<LineLayoutCache::Cache>(wParam));
+ case Message::SetLayoutCache:
+ if (static_cast<LineCache>(wParam) <= LineCache::Document) {
+ view.llc.SetLevel(static_cast<LineCache>(wParam));
}
break;
- case SCI_GETLAYOUTCACHE:
+ case Message::GetLayoutCache:
return static_cast<sptr_t>(view.llc.GetLevel());
- case SCI_SETPOSITIONCACHE:
+ case Message::SetPositionCache:
view.posCache.SetSize(wParam);
break;
- case SCI_GETPOSITIONCACHE:
+ case Message::GetPositionCache:
return view.posCache.GetSize();
- case SCI_SETSCROLLWIDTH:
+ case Message::SetScrollWidth:
PLATFORM_ASSERT(wParam > 0);
if ((wParam > 0) && (wParam != static_cast<unsigned int>(scrollWidth))) {
view.lineWidthMaxSeen = 0;
@@ -6787,34 +6799,34 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETSCROLLWIDTH:
+ case Message::GetScrollWidth:
return scrollWidth;
- case SCI_SETSCROLLWIDTHTRACKING:
+ case Message::SetScrollWidthTracking:
trackLineWidth = wParam != 0;
break;
- case SCI_GETSCROLLWIDTHTRACKING:
+ case Message::GetScrollWidthTracking:
return trackLineWidth;
- case SCI_LINESJOIN:
+ case Message::LinesJoin:
LinesJoin();
break;
- case SCI_LINESSPLIT:
+ case Message::LinesSplit:
LinesSplit(static_cast<int>(wParam));
break;
- case SCI_TEXTWIDTH:
+ case Message::TextWidth:
PLATFORM_ASSERT(wParam < vs.styles.size());
PLATFORM_ASSERT(lParam);
return TextWidth(wParam, CharPtrFromSPtr(lParam));
- case SCI_TEXTHEIGHT:
+ case Message::TextHeight:
RefreshStyleData();
return vs.lineHeight;
- case SCI_SETENDATLASTLINE:
+ case Message::SetEndAtLastLine:
PLATFORM_ASSERT((wParam == 0) || (wParam == 1));
if (endAtLastLine != (wParam != 0)) {
endAtLastLine = wParam != 0;
@@ -6822,30 +6834,30 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETENDATLASTLINE:
+ case Message::GetEndAtLastLine:
return endAtLastLine;
- case SCI_SETCARETSTICKY:
- PLATFORM_ASSERT(wParam <= SC_CARETSTICKY_WHITESPACE);
- if (wParam <= SC_CARETSTICKY_WHITESPACE) {
- caretSticky = static_cast<int>(wParam);
+ case Message::SetCaretSticky:
+ PLATFORM_ASSERT(static_cast<CaretSticky>(wParam) <= CaretSticky::WhiteSpace);
+ if (static_cast<CaretSticky>(wParam) <= CaretSticky::WhiteSpace) {
+ caretSticky = static_cast<CaretSticky>(wParam);
}
break;
- case SCI_GETCARETSTICKY:
- return caretSticky;
+ case Message::GetCaretSticky:
+ return static_cast<sptr_t>(caretSticky);
- case SCI_TOGGLECARETSTICKY:
- caretSticky = !caretSticky;
+ case Message::ToggleCaretSticky:
+ caretSticky = (caretSticky == CaretSticky::Off) ? CaretSticky::On : CaretSticky::Off;
break;
- case SCI_GETCOLUMN:
+ case Message::GetColumn:
return pdoc->GetColumn(static_cast<Sci::Position>(wParam));
- case SCI_FINDCOLUMN:
+ case Message::FindColumn:
return pdoc->FindColumn(static_cast<Sci::Line>(wParam), lParam);
- case SCI_SETHSCROLLBAR :
+ case Message::SetHScrollBar :
if (horizontalScrollBarVisible != (wParam != 0)) {
horizontalScrollBarVisible = wParam != 0;
SetScrollBars();
@@ -6853,10 +6865,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETHSCROLLBAR:
+ case Message::GetHScrollBar:
return horizontalScrollBarVisible;
- case SCI_SETVSCROLLBAR:
+ case Message::SetVScrollBar:
if (verticalScrollBarVisible != (wParam != 0)) {
verticalScrollBarVisible = wParam != 0;
SetScrollBars();
@@ -6866,31 +6878,31 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETVSCROLLBAR:
+ case Message::GetVScrollBar:
return verticalScrollBarVisible;
- case SCI_SETINDENTATIONGUIDES:
+ case Message::SetIndentationGuides:
vs.viewIndentationGuides = static_cast<IndentView>(wParam);
Redraw();
break;
- case SCI_GETINDENTATIONGUIDES:
+ case Message::GetIndentationGuides:
return static_cast<sptr_t>(vs.viewIndentationGuides);
- case SCI_SETHIGHLIGHTGUIDE:
+ case Message::SetHighlightGuide:
if ((highlightGuideColumn != static_cast<int>(wParam)) || (wParam > 0)) {
highlightGuideColumn = static_cast<int>(wParam);
Redraw();
}
break;
- case SCI_GETHIGHLIGHTGUIDE:
+ case Message::GetHighlightGuide:
return highlightGuideColumn;
- case SCI_GETLINEENDPOSITION:
+ case Message::GetLineEndPosition:
return pdoc->LineEnd(static_cast<Sci::Line>(wParam));
- case SCI_SETCODEPAGE:
+ case Message::SetCodePage:
if (ValidCodePage(static_cast<int>(wParam))) {
if (pdoc->SetDBCSCodePage(static_cast<int>(wParam))) {
pcs->Clear();
@@ -6902,147 +6914,147 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETCODEPAGE:
+ case Message::GetCodePage:
return pdoc->dbcsCodePage;
- case SCI_SETIMEINTERACTION:
- imeInteraction = static_cast<EditModel::IMEInteraction>(wParam);
+ case Message::SetIMEInteraction:
+ imeInteraction = static_cast<IMEInteraction>(wParam);
break;
- case SCI_GETIMEINTERACTION:
+ case Message::GetIMEInteraction:
return static_cast<sptr_t>(imeInteraction);
- case SCI_SETBIDIRECTIONAL:
- // SCI_SETBIDIRECTIONAL is implemented on platform subclasses if they support bidirectional text.
+ case Message::SetBidirectional:
+ // Message::SetBidirectional is implemented on platform subclasses if they support bidirectional text.
break;
- case SCI_GETBIDIRECTIONAL:
+ case Message::GetBidirectional:
return static_cast<sptr_t>(bidirectional);
- case SCI_GETLINECHARACTERINDEX:
- return pdoc->LineCharacterIndex();
+ case Message::GetLineCharacterIndex:
+ return static_cast<sptr_t>(pdoc->LineCharacterIndex());
- case SCI_ALLOCATELINECHARACTERINDEX:
- pdoc->AllocateLineCharacterIndex(static_cast<int>(wParam));
+ case Message::AllocateLineCharacterIndex:
+ pdoc->AllocateLineCharacterIndex(static_cast<LineCharacterIndexType>(wParam));
break;
- case SCI_RELEASELINECHARACTERINDEX:
- pdoc->ReleaseLineCharacterIndex(static_cast<int>(wParam));
+ case Message::ReleaseLineCharacterIndex:
+ pdoc->ReleaseLineCharacterIndex(static_cast<LineCharacterIndexType>(wParam));
break;
- case SCI_LINEFROMINDEXPOSITION:
- return pdoc->LineFromPositionIndex(static_cast<Sci::Position>(wParam), static_cast<int>(lParam));
+ case Message::LineFromIndexPosition:
+ return pdoc->LineFromPositionIndex(static_cast<Sci::Position>(wParam), static_cast<LineCharacterIndexType>(lParam));
- case SCI_INDEXPOSITIONFROMLINE:
- return pdoc->IndexLineStart(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
+ case Message::IndexPositionFromLine:
+ return pdoc->IndexLineStart(static_cast<Sci::Line>(wParam), static_cast<LineCharacterIndexType>(lParam));
// Marker definition and setting
- case SCI_MARKERDEFINE:
- if (wParam <= MARKER_MAX) {
- vs.markers[wParam].markType = static_cast<int>(lParam);
+ case Message::MarkerDefine:
+ if (wParam <= MarkerMax) {
+ vs.markers[wParam].markType = static_cast<MarkerSymbol>(lParam);
vs.CalcLargestMarkerHeight();
}
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSYMBOLDEFINED:
- if (wParam <= MARKER_MAX)
- return vs.markers[wParam].markType;
+ case Message::MarkerSymbolDefined:
+ if (wParam <= MarkerMax)
+ return static_cast<sptr_t>(vs.markers[wParam].markType);
else
return 0;
- case SCI_MARKERSETFORE:
- if (wParam <= MARKER_MAX)
+ case Message::MarkerSetFore:
+ if (wParam <= MarkerMax)
vs.markers[wParam].fore = ColourRGBA::FromRGB(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSETBACK:
- if (wParam <= MARKER_MAX)
+ case Message::MarkerSetBack:
+ if (wParam <= MarkerMax)
vs.markers[wParam].back = ColourRGBA::FromRGB(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSETBACKSELECTED:
- if (wParam <= MARKER_MAX)
+ case Message::MarkerSetBackSelected:
+ if (wParam <= MarkerMax)
vs.markers[wParam].backSelected = ColourRGBA::FromRGB(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSETFORETRANSLUCENT:
- if (wParam <= MARKER_MAX)
+ case Message::MarkerSetForeTranslucent:
+ if (wParam <= MarkerMax)
vs.markers[wParam].fore = ColourRGBA(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSETBACKTRANSLUCENT:
- if (wParam <= MARKER_MAX)
+ case Message::MarkerSetBackTranslucent:
+ if (wParam <= MarkerMax)
vs.markers[wParam].back = ColourRGBA(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSETBACKSELECTEDTRANSLUCENT:
- if (wParam <= MARKER_MAX)
+ case Message::MarkerSetBackSelectedTranslucent:
+ if (wParam <= MarkerMax)
vs.markers[wParam].backSelected = ColourRGBA(static_cast<int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERSETSTROKEWIDTH:
- if (wParam <= MARKER_MAX)
+ case Message::MarkerSetStrokeWidth:
+ if (wParam <= MarkerMax)
vs.markers[wParam].strokeWidth = lParam / 100.0f;
InvalidateStyleData();
RedrawSelMargin();
break;
- case SCI_MARKERENABLEHIGHLIGHT:
+ case Message::MarkerEnableHighlight:
marginView.highlightDelimiter.isEnabled = wParam == 1;
RedrawSelMargin();
break;
- case SCI_MARKERSETALPHA:
- if (wParam <= MARKER_MAX) {
- if (lParam == SC_ALPHA_NOALPHA) {
- SetAppearance(vs.markers[wParam].alpha, 0xff);
- SetAppearance(vs.markers[wParam].layer, Layer::base);
+ case Message::MarkerSetAlpha:
+ if (wParam <= MarkerMax) {
+ if (static_cast<Alpha>(lParam) == Alpha::NoAlpha) {
+ SetAppearance(vs.markers[wParam].alpha, Alpha::Opaque);
+ SetAppearance(vs.markers[wParam].layer, Layer::Base);
} else {
- SetAppearance(vs.markers[wParam].alpha, static_cast<int>(lParam));
- SetAppearance(vs.markers[wParam].layer, Layer::over);
+ SetAppearance(vs.markers[wParam].alpha, static_cast<Alpha>(lParam));
+ SetAppearance(vs.markers[wParam].layer, Layer::OverText);
}
}
break;
- case SCI_MARKERSETLAYER:
- if (wParam <= MARKER_MAX) {
+ case Message::MarkerSetLayer:
+ if (wParam <= MarkerMax) {
SetAppearance(vs.markers[wParam].layer, static_cast<Layer>(lParam));
}
break;
- case SCI_MARKERGETLAYER:
- if (wParam <= MARKER_MAX) {
+ case Message::MarkerGetLayer:
+ if (wParam <= MarkerMax) {
return static_cast<sptr_t>(vs.markers[wParam].layer);
}
return 0;
- case SCI_MARKERADD: {
+ case Message::MarkerAdd: {
const int markerID = pdoc->AddMark(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
return markerID;
}
- case SCI_MARKERADDSET:
+ case Message::MarkerAddSet:
if (lParam != 0)
pdoc->AddMarkSet(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
break;
- case SCI_MARKERDELETE:
+ case Message::MarkerDelete:
pdoc->DeleteMark(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
break;
- case SCI_MARKERDELETEALL:
+ case Message::MarkerDeleteAll:
pdoc->DeleteAllMarks(static_cast<int>(wParam));
break;
- case SCI_MARKERGET:
+ case Message::MarkerGet:
return pdoc->GetMark(static_cast<Sci::Line>(wParam));
- case SCI_MARKERNEXT:
+ case Message::MarkerNext:
return pdoc->MarkerNext(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
- case SCI_MARKERPREVIOUS: {
+ case Message::MarkerPrevious: {
for (Sci::Line iLine = static_cast<Sci::Line>(wParam); iLine >= 0; iLine--) {
if ((pdoc->GetMark(iLine) & lParam) != 0)
return iLine;
@@ -7050,8 +7062,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
return -1;
- case SCI_MARKERDEFINEPIXMAP:
- if (wParam <= MARKER_MAX) {
+ case Message::MarkerDefinePixmap:
+ if (wParam <= MarkerMax) {
vs.markers[wParam].SetXPM(CharPtrFromSPtr(lParam));
vs.CalcLargestMarkerHeight();
}
@@ -7059,20 +7071,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
RedrawSelMargin();
break;
- case SCI_RGBAIMAGESETWIDTH:
+ case Message::RGBAImageSetWidth:
sizeRGBAImage.x = static_cast<XYPOSITION>(wParam);
break;
- case SCI_RGBAIMAGESETHEIGHT:
+ case Message::RGBAImageSetHeight:
sizeRGBAImage.y = static_cast<XYPOSITION>(wParam);
break;
- case SCI_RGBAIMAGESETSCALE:
+ case Message::RGBAImageSetScale:
scaleRGBAImage = static_cast<float>(wParam);
break;
- case SCI_MARKERDEFINERGBAIMAGE:
- if (wParam <= MARKER_MAX) {
+ case Message::MarkerDefineRGBAImage:
+ if (wParam <= MarkerMax) {
vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, ConstUCharPtrFromSPtr(lParam));
vs.CalcLargestMarkerHeight();
}
@@ -7080,20 +7092,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
RedrawSelMargin();
break;
- case SCI_SETMARGINTYPEN:
+ case Message::SetMarginTypeN:
if (ValidMargin(wParam)) {
- vs.ms[wParam].style = static_cast<int>(lParam);
+ vs.ms[wParam].style = static_cast<MarginType>(lParam);
InvalidateStyleRedraw();
}
break;
- case SCI_GETMARGINTYPEN:
+ case Message::GetMarginTypeN:
if (ValidMargin(wParam))
- return vs.ms[wParam].style;
+ return static_cast<sptr_t>(vs.ms[wParam].style);
else
return 0;
- case SCI_SETMARGINWIDTHN:
+ case Message::SetMarginWidthN:
if (ValidMargin(wParam)) {
// Short-circuit if the width is unchanged, to avoid unnecessary redraw.
if (vs.ms[wParam].width != lParam) {
@@ -7104,147 +7116,147 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETMARGINWIDTHN:
+ case Message::GetMarginWidthN:
if (ValidMargin(wParam))
return vs.ms[wParam].width;
else
return 0;
- case SCI_SETMARGINMASKN:
+ case Message::SetMarginMaskN:
if (ValidMargin(wParam)) {
vs.ms[wParam].mask = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
- case SCI_GETMARGINMASKN:
+ case Message::GetMarginMaskN:
if (ValidMargin(wParam))
return vs.ms[wParam].mask;
else
return 0;
- case SCI_SETMARGINSENSITIVEN:
+ case Message::SetMarginSensitiveN:
if (ValidMargin(wParam)) {
vs.ms[wParam].sensitive = lParam != 0;
InvalidateStyleRedraw();
}
break;
- case SCI_GETMARGINSENSITIVEN:
+ case Message::GetMarginSensitiveN:
if (ValidMargin(wParam))
return vs.ms[wParam].sensitive ? 1 : 0;
else
return 0;
- case SCI_SETMARGINCURSORN:
+ case Message::SetMarginCursorN:
if (ValidMargin(wParam))
- vs.ms[wParam].cursor = static_cast<int>(lParam);
+ vs.ms[wParam].cursor = static_cast<CursorShape>(lParam);
break;
- case SCI_GETMARGINCURSORN:
+ case Message::GetMarginCursorN:
if (ValidMargin(wParam))
- return vs.ms[wParam].cursor;
+ return static_cast<sptr_t>(vs.ms[wParam].cursor);
else
return 0;
- case SCI_SETMARGINBACKN:
+ case Message::SetMarginBackN:
if (ValidMargin(wParam)) {
vs.ms[wParam].back = ColourRGBA::FromRGB(static_cast<int>(lParam));
InvalidateStyleRedraw();
}
break;
- case SCI_GETMARGINBACKN:
+ case Message::GetMarginBackN:
if (ValidMargin(wParam))
return vs.ms[wParam].back.OpaqueRGB();
else
return 0;
- case SCI_SETMARGINS:
+ case Message::SetMargins:
if (wParam < 1000)
vs.ms.resize(wParam);
break;
- case SCI_GETMARGINS:
+ case Message::GetMargins:
return vs.ms.size();
- case SCI_STYLECLEARALL:
+ case Message::StyleClearAll:
vs.ClearStyles();
InvalidateStyleRedraw();
break;
- case SCI_STYLESETFORE:
- case SCI_STYLESETBACK:
- case SCI_STYLESETBOLD:
- case SCI_STYLESETWEIGHT:
- case SCI_STYLESETITALIC:
- case SCI_STYLESETEOLFILLED:
- case SCI_STYLESETSIZE:
- case SCI_STYLESETSIZEFRACTIONAL:
- case SCI_STYLESETFONT:
- case SCI_STYLESETUNDERLINE:
- case SCI_STYLESETCASE:
- case SCI_STYLESETCHARACTERSET:
- case SCI_STYLESETVISIBLE:
- case SCI_STYLESETCHANGEABLE:
- case SCI_STYLESETHOTSPOT:
+ case Message::StyleSetFore:
+ case Message::StyleSetBack:
+ case Message::StyleSetBold:
+ case Message::StyleSetWeight:
+ case Message::StyleSetItalic:
+ case Message::StyleSetEOLFilled:
+ case Message::StyleSetSize:
+ case Message::StyleSetSizeFractional:
+ case Message::StyleSetFont:
+ case Message::StyleSetUnderline:
+ case Message::StyleSetCase:
+ case Message::StyleSetCharacterSet:
+ case Message::StyleSetVisible:
+ case Message::StyleSetChangeable:
+ case Message::StyleSetHotSpot:
StyleSetMessage(iMessage, wParam, lParam);
break;
- case SCI_STYLEGETFORE:
- case SCI_STYLEGETBACK:
- case SCI_STYLEGETBOLD:
- case SCI_STYLEGETWEIGHT:
- case SCI_STYLEGETITALIC:
- case SCI_STYLEGETEOLFILLED:
- case SCI_STYLEGETSIZE:
- case SCI_STYLEGETSIZEFRACTIONAL:
- case SCI_STYLEGETFONT:
- case SCI_STYLEGETUNDERLINE:
- case SCI_STYLEGETCASE:
- case SCI_STYLEGETCHARACTERSET:
- case SCI_STYLEGETVISIBLE:
- case SCI_STYLEGETCHANGEABLE:
- case SCI_STYLEGETHOTSPOT:
+ case Message::StyleGetFore:
+ case Message::StyleGetBack:
+ case Message::StyleGetBold:
+ case Message::StyleGetWeight:
+ case Message::StyleGetItalic:
+ case Message::StyleGetEOLFilled:
+ case Message::StyleGetSize:
+ case Message::StyleGetSizeFractional:
+ case Message::StyleGetFont:
+ case Message::StyleGetUnderline:
+ case Message::StyleGetCase:
+ case Message::StyleGetCharacterSet:
+ case Message::StyleGetVisible:
+ case Message::StyleGetChangeable:
+ case Message::StyleGetHotSpot:
return StyleGetMessage(iMessage, wParam, lParam);
- case SCI_STYLERESETDEFAULT:
+ case Message::StyleResetDefault:
vs.ResetDefaultStyle();
InvalidateStyleRedraw();
break;
- case SCI_SETELEMENTCOLOUR:
- if (vs.SetElementColour(static_cast<int>(wParam), ColourRGBA(static_cast<int>(lParam)))) {
+ case Message::SetElementColour:
+ if (vs.SetElementColour(static_cast<Element>(wParam), ColourRGBA(static_cast<int>(lParam)))) {
InvalidateStyleRedraw();
}
break;
- case SCI_GETELEMENTCOLOUR:
- return vs.ElementColour(static_cast<int>(wParam)).value_or(ColourRGBA()).AsInteger();
+ case Message::GetElementColour:
+ return vs.ElementColour(static_cast<Element>(wParam)).value_or(ColourRGBA()).AsInteger();
- case SCI_RESETELEMENTCOLOUR:
- if (vs.ResetElement(static_cast<int>(wParam))) {
+ case Message::ResetElementColour:
+ if (vs.ResetElement(static_cast<Element>(wParam))) {
InvalidateStyleRedraw();
}
break;
- case SCI_GETELEMENTISSET:
- return vs.ElementColour(static_cast<int>(wParam)).has_value();
+ case Message::GetElementIsSet:
+ return vs.ElementColour(static_cast<Element>(wParam)).has_value();
- case SCI_GETELEMENTALLOWSTRANSLUCENT:
- return vs.ElementAllowsTranslucent(static_cast<int>(wParam));
+ case Message::GetElementAllowsTranslucent:
+ return vs.ElementAllowsTranslucent(static_cast<Element>(wParam));
- case SCI_GETELEMENTBASECOLOUR:
- return vs.elementBaseColours[static_cast<int>(wParam)].value_or(ColourRGBA()).AsInteger();
+ case Message::GetElementBaseColour:
+ return vs.elementBaseColours[static_cast<Element>(wParam)].value_or(ColourRGBA()).AsInteger();
- case SCI_SETFONTLOCALE:
+ case Message::SetFontLocale:
if (lParam) {
vs.SetFontLocaleName(CharPtrFromSPtr(lParam));
InvalidateStyleRedraw();
}
break;
- case SCI_GETFONTLOCALE:
+ case Message::GetFontLocale:
return StringResult(lParam, vs.localeName.c_str());
#ifdef INCLUDE_DEPRECATED_FEATURES
@@ -7256,57 +7268,57 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 8;
#endif
- case SCI_SETLINESTATE:
+ case Message::SetLineState:
return pdoc->SetLineState(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
- case SCI_GETLINESTATE:
+ case Message::GetLineState:
return pdoc->GetLineState(static_cast<Sci::Line>(wParam));
- case SCI_GETMAXLINESTATE:
+ case Message::GetMaxLineState:
return pdoc->GetMaxLineState();
- case SCI_GETCARETLINEVISIBLE:
- return vs.ElementColour(SC_ELEMENT_CARET_LINE_BACK) ? 1 : 0;
- case SCI_SETCARETLINEVISIBLE:
+ case Message::GetCaretLineVisible:
+ return vs.ElementColour(Element::CaretLineBack) ? 1 : 0;
+ case Message::SetCaretLineVisible:
if (wParam) {
- if (!vs.elementColours.count(SC_ELEMENT_CARET_LINE_BACK)) {
- vs.elementColours[SC_ELEMENT_CARET_LINE_BACK] = ColourRGBA(0xFF, 0xFF, 0);
+ if (!vs.elementColours.count(Element::CaretLineBack)) {
+ vs.elementColours[Element::CaretLineBack] = ColourRGBA(0xFF, 0xFF, 0);
InvalidateStyleRedraw();
}
} else {
- if (vs.ResetElement(SC_ELEMENT_CARET_LINE_BACK)) {
+ if (vs.ResetElement(Element::CaretLineBack)) {
InvalidateStyleRedraw();
}
}
break;
- case SCI_GETCARETLINEVISIBLEALWAYS:
+ case Message::GetCaretLineVisibleAlways:
return vs.caretLine.alwaysShow;
- case SCI_SETCARETLINEVISIBLEALWAYS:
+ case Message::SetCaretLineVisibleAlways:
vs.caretLine.alwaysShow = wParam != 0;
InvalidateStyleRedraw();
break;
- case SCI_GETCARETLINEFRAME:
+ case Message::GetCaretLineFrame:
return vs.caretLine.frame;
- case SCI_SETCARETLINEFRAME:
+ case Message::SetCaretLineFrame:
vs.caretLine.frame = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_GETCARETLINEBACK:
- if (vs.ElementColour(SC_ELEMENT_CARET_LINE_BACK))
- return vs.ElementColour(SC_ELEMENT_CARET_LINE_BACK)->OpaqueRGB();
+ case Message::GetCaretLineBack:
+ if (vs.ElementColour(Element::CaretLineBack))
+ return vs.ElementColour(Element::CaretLineBack)->OpaqueRGB();
else
return 0;
- case SCI_SETCARETLINEBACK:
- vs.SetElementRGB(SC_ELEMENT_CARET_LINE_BACK, static_cast<int>(wParam));
+ case Message::SetCaretLineBack:
+ vs.SetElementRGB(Element::CaretLineBack, static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_GETCARETLINELAYER:
+ case Message::GetCaretLineLayer:
return static_cast<sptr_t>(vs.caretLine.layer);
- case SCI_SETCARETLINELAYER:
+ case Message::SetCaretLineLayer:
if (vs.caretLine.layer != static_cast<Layer>(wParam)) {
vs.caretLine.layer = static_cast<Layer>(wParam);
UpdateBaseElements();
@@ -7314,16 +7326,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETCARETLINEBACKALPHA:
- if (vs.caretLine.layer == Layer::base)
- return SC_ALPHA_NOALPHA;
- return vs.ElementColour(SC_ELEMENT_CARET_LINE_BACK).value_or(ColourRGBA()).GetAlpha();
+ case Message::GetCaretLineBackAlpha:
+ if (vs.caretLine.layer == Layer::Base)
+ return static_cast<sptr_t>(Alpha::NoAlpha);
+ return vs.ElementColour(Element::CaretLineBack).value_or(ColourRGBA()).GetAlpha();
- case SCI_SETCARETLINEBACKALPHA: {
- const Layer layerNew = (wParam == SC_ALPHA_NOALPHA) ? Layer::base : Layer::over;
+ case Message::SetCaretLineBackAlpha: {
+ const Layer layerNew = (static_cast<Alpha>(wParam) == Alpha::NoAlpha) ? Layer::Base : Layer::OverText;
vs.caretLine.layer = layerNew;
- if (vs.ElementColour(SC_ELEMENT_CARET_LINE_BACK)) {
- vs.SetElementAlpha(SC_ELEMENT_CARET_LINE_BACK, static_cast<int>(wParam));
+ if (vs.ElementColour(Element::CaretLineBack)) {
+ vs.SetElementAlpha(Element::CaretLineBack, static_cast<int>(wParam));
}
InvalidateStyleRedraw();
}
@@ -7331,206 +7343,206 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
// Folding messages
- case SCI_VISIBLEFROMDOCLINE:
+ case Message::VisibleFromDocLine:
return pcs->DisplayFromDoc(static_cast<Sci::Line>(wParam));
- case SCI_DOCLINEFROMVISIBLE:
+ case Message::DocLineFromVisible:
return pcs->DocFromDisplay(static_cast<Sci::Line>(wParam));
- case SCI_WRAPCOUNT:
+ case Message::WrapCount:
return WrapCount(static_cast<Sci::Line>(wParam));
- case SCI_SETFOLDLEVEL: {
+ case Message::SetFoldLevel: {
const int prev = pdoc->SetLevel(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
if (prev != static_cast<int>(lParam))
RedrawSelMargin();
return prev;
}
- case SCI_GETFOLDLEVEL:
+ case Message::GetFoldLevel:
return pdoc->GetLevel(static_cast<Sci::Line>(wParam));
- case SCI_GETLASTCHILD:
- return pdoc->GetLastChild(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
+ case Message::GetLastChild:
+ return pdoc->GetLastChild(static_cast<Sci::Line>(wParam), static_cast<FoldLevel>(lParam));
- case SCI_GETFOLDPARENT:
+ case Message::GetFoldParent:
return pdoc->GetFoldParent(static_cast<Sci::Line>(wParam));
- case SCI_SHOWLINES:
+ case Message::ShowLines:
pcs->SetVisible(static_cast<Sci::Line>(wParam), static_cast<Sci::Line>(lParam), true);
SetScrollBars();
Redraw();
break;
- case SCI_HIDELINES:
+ case Message::HideLines:
if (wParam > 0)
pcs->SetVisible(static_cast<Sci::Line>(wParam), static_cast<Sci::Line>(lParam), false);
SetScrollBars();
Redraw();
break;
- case SCI_GETLINEVISIBLE:
+ case Message::GetLineVisible:
return pcs->GetVisible(static_cast<Sci::Line>(wParam));
- case SCI_GETALLLINESVISIBLE:
+ case Message::GetAllLinesVisible:
return pcs->HiddenLines() ? 0 : 1;
- case SCI_SETFOLDEXPANDED:
+ case Message::SetFoldExpanded:
SetFoldExpanded(static_cast<Sci::Line>(wParam), lParam != 0);
break;
- case SCI_GETFOLDEXPANDED:
+ case Message::GetFoldExpanded:
return pcs->GetExpanded(static_cast<Sci::Line>(wParam));
- case SCI_SETAUTOMATICFOLD:
- foldAutomatic = static_cast<int>(wParam);
+ case Message::SetAutomaticFold:
+ foldAutomatic = static_cast<AutomaticFold>(wParam);
break;
- case SCI_GETAUTOMATICFOLD:
- return foldAutomatic;
+ case Message::GetAutomaticFold:
+ return static_cast<sptr_t>(foldAutomatic);
- case SCI_SETFOLDFLAGS:
- foldFlags = static_cast<int>(wParam);
+ case Message::SetFoldFlags:
+ foldFlags = static_cast<FoldFlag>(wParam);
Redraw();
break;
- case SCI_TOGGLEFOLDSHOWTEXT:
+ case Message::ToggleFoldShowText:
pcs->SetFoldDisplayText(static_cast<Sci::Line>(wParam), CharPtrFromSPtr(lParam));
- FoldLine(static_cast<Sci::Line>(wParam), SC_FOLDACTION_TOGGLE);
+ FoldLine(static_cast<Sci::Line>(wParam), FoldAction::Toggle);
break;
- case SCI_FOLDDISPLAYTEXTSETSTYLE:
- foldDisplayTextStyle = static_cast<int>(wParam);
+ case Message::FoldDisplayTextSetStyle:
+ foldDisplayTextStyle = static_cast<FoldDisplayTextStyle>(wParam);
Redraw();
break;
- case SCI_FOLDDISPLAYTEXTGETSTYLE:
- return foldDisplayTextStyle;
+ case Message::FoldDisplayTextGetStyle:
+ return static_cast<sptr_t>(foldDisplayTextStyle);
- case SCI_SETDEFAULTFOLDDISPLAYTEXT:
+ case Message::SetDefaultFoldDisplayText:
SetDefaultFoldDisplayText(CharPtrFromSPtr(lParam));
Redraw();
break;
- case SCI_GETDEFAULTFOLDDISPLAYTEXT:
+ case Message::GetDefaultFoldDisplayText:
return StringResult(lParam, GetDefaultFoldDisplayText());
- case SCI_TOGGLEFOLD:
- FoldLine(static_cast<Sci::Line>(wParam), SC_FOLDACTION_TOGGLE);
+ case Message::ToggleFold:
+ FoldLine(static_cast<Sci::Line>(wParam), FoldAction::Toggle);
break;
- case SCI_FOLDLINE:
- FoldLine(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
+ case Message::FoldLine:
+ FoldLine(static_cast<Sci::Line>(wParam), static_cast<FoldAction>(lParam));
break;
- case SCI_FOLDCHILDREN:
- FoldExpand(static_cast<Sci::Line>(wParam), static_cast<int>(lParam), pdoc->GetLevel(static_cast<int>(wParam)));
+ case Message::FoldChildren:
+ FoldExpand(static_cast<Sci::Line>(wParam), static_cast<FoldAction>(lParam), pdoc->GetFoldLevel(static_cast<int>(wParam)));
break;
- case SCI_FOLDALL:
- FoldAll(static_cast<int>(wParam));
+ case Message::FoldAll:
+ FoldAll(static_cast<FoldAction>(wParam));
break;
- case SCI_EXPANDCHILDREN:
- FoldExpand(static_cast<Sci::Line>(wParam), SC_FOLDACTION_EXPAND, static_cast<int>(lParam));
+ case Message::ExpandChildren:
+ FoldExpand(static_cast<Sci::Line>(wParam), FoldAction::Expand, static_cast<FoldLevel>(lParam));
break;
- case SCI_CONTRACTEDFOLDNEXT:
+ case Message::ContractedFoldNext:
return ContractedFoldNext(static_cast<Sci::Line>(wParam));
- case SCI_ENSUREVISIBLE:
+ case Message::EnsureVisible:
EnsureLineVisible(static_cast<Sci::Line>(wParam), false);
break;
- case SCI_ENSUREVISIBLEENFORCEPOLICY:
+ case Message::EnsureVisibleEnforcePolicy:
EnsureLineVisible(static_cast<Sci::Line>(wParam), true);
break;
- case SCI_SCROLLRANGE:
+ case Message::ScrollRange:
ScrollRange(SelectionRange(static_cast<Sci::Position>(wParam), lParam));
break;
- case SCI_SEARCHANCHOR:
+ case Message::SearchAnchor:
SearchAnchor();
break;
- case SCI_SEARCHNEXT:
- case SCI_SEARCHPREV:
+ case Message::SearchNext:
+ case Message::SearchPrev:
return SearchText(iMessage, wParam, lParam);
- case SCI_SETXCARETPOLICY:
- caretPolicies.x = CaretPolicy(wParam, lParam);
+ case Message::SetXCaretPolicy:
+ caretPolicies.x = CaretPolicySlop(wParam, lParam);
break;
- case SCI_SETYCARETPOLICY:
- caretPolicies.y = CaretPolicy(wParam, lParam);
+ case Message::SetYCaretPolicy:
+ caretPolicies.y = CaretPolicySlop(wParam, lParam);
break;
- case SCI_SETVISIBLEPOLICY:
- visiblePolicy = CaretPolicy(wParam, lParam);
+ case Message::SetVisiblePolicy:
+ visiblePolicy = VisiblePolicySlop(wParam, lParam);
break;
- case SCI_LINESONSCREEN:
+ case Message::LinesOnScreen:
return LinesOnScreen();
- case SCI_SETSELFORE:
- vs.elementColours[SC_ELEMENT_SELECTION_TEXT] = OptionalColour(wParam, lParam);
- vs.elementColours[SC_ELEMENT_SELECTION_ADDITIONAL_TEXT] = OptionalColour(wParam, lParam);
+ case Message::SetSelFore:
+ vs.elementColours[Element::SelectionText] = OptionalColour(wParam, lParam);
+ vs.elementColours[Element::SelectionAdditionalText] = OptionalColour(wParam, lParam);
InvalidateStyleRedraw();
break;
- case SCI_SETSELBACK:
+ case Message::SetSelBack:
if (wParam) {
- vs.SetElementRGB(SC_ELEMENT_SELECTION_BACK, static_cast<int>(lParam));
- vs.SetElementRGB(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, static_cast<int>(lParam));
+ vs.SetElementRGB(Element::SelectionBack, static_cast<int>(lParam));
+ vs.SetElementRGB(Element::SelectionAdditionalBack, static_cast<int>(lParam));
} else {
- vs.ResetElement(SC_ELEMENT_SELECTION_BACK);
- vs.ResetElement(SC_ELEMENT_SELECTION_ADDITIONAL_BACK);
+ vs.ResetElement(Element::SelectionBack);
+ vs.ResetElement(Element::SelectionAdditionalBack);
}
InvalidateStyleRedraw();
break;
- case SCI_SETSELALPHA: {
- const Layer layerNew = (wParam == SC_ALPHA_NOALPHA) ? Layer::base : Layer::over;
+ case Message::SetSelAlpha: {
+ const Layer layerNew = (static_cast<Alpha>(wParam) == Alpha::NoAlpha) ? Layer::Base : Layer::OverText;
if (vs.selection.layer != layerNew) {
vs.selection.layer = layerNew;
UpdateBaseElements();
}
const int alpha = static_cast<int>(wParam);
- vs.SetElementAlpha(SC_ELEMENT_SELECTION_BACK, alpha);
- vs.SetElementAlpha(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, alpha);
- vs.SetElementAlpha(SC_ELEMENT_SELECTION_SECONDARY_BACK, alpha);
- vs.SetElementAlpha(SC_ELEMENT_SELECTION_NO_FOCUS_BACK, alpha);
+ vs.SetElementAlpha(Element::SelectionBack, alpha);
+ vs.SetElementAlpha(Element::SelectionAdditionalBack, alpha);
+ vs.SetElementAlpha(Element::SelectionSecondaryBack, alpha);
+ vs.SetElementAlpha(Element::SelectionNoFocusBack, alpha);
InvalidateStyleRedraw();
}
break;
- case SCI_GETSELALPHA:
- if (vs.selection.layer == Layer::base)
- return SC_ALPHA_NOALPHA;
- return vs.ElementColour(SC_ELEMENT_SELECTION_BACK)->GetAlpha();
+ case Message::GetSelAlpha:
+ if (vs.selection.layer == Layer::Base)
+ return static_cast<sptr_t>(Alpha::NoAlpha);
+ return vs.ElementColour(Element::SelectionBack)->GetAlpha();
- case SCI_GETSELEOLFILLED:
+ case Message::GetSelEOLFilled:
return vs.selection.eolFilled;
- case SCI_SETSELEOLFILLED:
+ case Message::SetSelEOLFilled:
vs.selection.eolFilled = wParam != 0;
InvalidateStyleRedraw();
break;
- case SCI_SETWHITESPACEFORE:
- if (vs.SetElementColourOptional(SC_ELEMENT_WHITE_SPACE, wParam, lParam)) {
+ case Message::SetWhitespaceFore:
+ if (vs.SetElementColourOptional(Element::WhiteSpace, wParam, lParam)) {
InvalidateStyleRedraw();
}
break;
- case SCI_SETWHITESPACEBACK:
- if (vs.SetElementColourOptional(SC_ELEMENT_WHITE_SPACE_BACK, wParam, lParam)) {
+ case Message::SetWhitespaceBack:
+ if (vs.SetElementColourOptional(Element::WhiteSpaceBack, wParam, lParam)) {
InvalidateStyleRedraw();
}
break;
- case SCI_SETSELECTIONLAYER:
+ case Message::SetSelectionLayer:
if (vs.selection.layer != static_cast<Layer>(wParam)) {
vs.selection.layer = static_cast<Layer>(wParam);
UpdateBaseElements();
@@ -7538,313 +7550,320 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
- case SCI_GETSELECTIONLAYER:
+ case Message::GetSelectionLayer:
return static_cast<sptr_t>(vs.selection.layer);
- case SCI_SETCARETFORE:
- vs.elementColours[SC_ELEMENT_CARET] = ColourRGBA::FromRGB(static_cast<int>(wParam));
+ case Message::SetCaretFore:
+ vs.elementColours[Element::Caret] = ColourRGBA::FromRGB(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_GETCARETFORE:
- return vs.ElementColour(SC_ELEMENT_CARET)->OpaqueRGB();
+ case Message::GetCaretFore:
+ return vs.ElementColour(Element::Caret)->OpaqueRGB();
- case SCI_SETCARETSTYLE:
- if (wParam <= (CARETSTYLE_BLOCK | CARETSTYLE_OVERSTRIKE_BLOCK | CARETSTYLE_BLOCK_AFTER))
- vs.caret.style = static_cast<int>(wParam);
+ case Message::SetCaretStyle:
+ if (static_cast<CaretStyle>(wParam) <= (CaretStyle::Block | CaretStyle::OverstrikeBlock | CaretStyle::BlockAfter))
+ vs.caret.style = static_cast<CaretStyle>(wParam);
else
/* Default to the line caret */
- vs.caret.style = CARETSTYLE_LINE;
+ vs.caret.style = CaretStyle::Line;
InvalidateStyleRedraw();
break;
- case SCI_GETCARETSTYLE:
- return vs.caret.style;
+ case Message::GetCaretStyle:
+ return static_cast<sptr_t>(vs.caret.style);
- case SCI_SETCARETWIDTH:
+ case Message::SetCaretWidth:
vs.caret.width = std::clamp(static_cast<int>(wParam), 0, 20);
InvalidateStyleRedraw();
break;
- case SCI_GETCARETWIDTH:
+ case Message::GetCaretWidth:
return vs.caret.width;
- case SCI_ASSIGNCMDKEY:
- kmap.AssignCmdKey(LowShortFromWParam(wParam),
- HighShortFromWParam(wParam), static_cast<unsigned int>(lParam));
+ case Message::AssignCmdKey:
+ kmap.AssignCmdKey(static_cast<Keys>(LowShortFromWParam(wParam)),
+ static_cast<KeyMod>(HighShortFromWParam(wParam)), static_cast<Message>(lParam));
break;
- case SCI_CLEARCMDKEY:
- kmap.AssignCmdKey(LowShortFromWParam(wParam),
- HighShortFromWParam(wParam), SCI_NULL);
+ case Message::ClearCmdKey:
+ kmap.AssignCmdKey(static_cast<Keys>(LowShortFromWParam(wParam)),
+ static_cast<KeyMod>(HighShortFromWParam(wParam)), Message::Null);
break;
- case SCI_CLEARALLCMDKEYS:
+ case Message::ClearAllCmdKeys:
kmap.Clear();
break;
- case SCI_INDICSETSTYLE:
- if (wParam <= INDICATOR_MAX) {
- vs.indicators[wParam].sacNormal.style = static_cast<int>(lParam);
- vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
+ case Message::IndicSetStyle:
+ if (wParam <= IndicatorMax) {
+ vs.indicators[wParam].sacNormal.style = static_cast<IndicatorStyle>(lParam);
+ vs.indicators[wParam].sacHover.style = static_cast<IndicatorStyle>(lParam);
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETSTYLE:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].sacNormal.style : 0;
+ case Message::IndicGetStyle:
+ return (wParam <= IndicatorMax) ?
+ static_cast<sptr_t>(vs.indicators[wParam].sacNormal.style) : 0;
- case SCI_INDICSETFORE:
- if (wParam <= INDICATOR_MAX) {
+ case Message::IndicSetFore:
+ if (wParam <= IndicatorMax) {
vs.indicators[wParam].sacNormal.fore = ColourRGBA::FromRGB(static_cast<int>(lParam));
vs.indicators[wParam].sacHover.fore = ColourRGBA::FromRGB(static_cast<int>(lParam));
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETFORE:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].sacNormal.fore.OpaqueRGB() : 0;
+ case Message::IndicGetFore:
+ return (wParam <= IndicatorMax) ?
+ vs.indicators[wParam].sacNormal.fore.OpaqueRGB() : 0;
- case SCI_INDICSETHOVERSTYLE:
- if (wParam <= INDICATOR_MAX) {
- vs.indicators[wParam].sacHover.style = static_cast<int>(lParam);
+ case Message::IndicSetHoverStyle:
+ if (wParam <= IndicatorMax) {
+ vs.indicators[wParam].sacHover.style = static_cast<IndicatorStyle>(lParam);
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETHOVERSTYLE:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].sacHover.style : 0;
+ case Message::IndicGetHoverStyle:
+ return (wParam <= IndicatorMax) ?
+ static_cast<sptr_t>(vs.indicators[wParam].sacHover.style) : 0;
- case SCI_INDICSETHOVERFORE:
- if (wParam <= INDICATOR_MAX) {
+ case Message::IndicSetHoverFore:
+ if (wParam <= IndicatorMax) {
vs.indicators[wParam].sacHover.fore = ColourRGBA::FromRGB(static_cast<int>(lParam));
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETHOVERFORE:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].sacHover.fore.OpaqueRGB() : 0;
+ case Message::IndicGetHoverFore:
+ return (wParam <= IndicatorMax) ?
+ vs.indicators[wParam].sacHover.fore.OpaqueRGB() : 0;
- case SCI_INDICSETFLAGS:
- if (wParam <= INDICATOR_MAX) {
- vs.indicators[wParam].SetFlags(static_cast<int>(lParam));
+ case Message::IndicSetFlags:
+ if (wParam <= IndicatorMax) {
+ vs.indicators[wParam].SetFlags(static_cast<IndicFlag>(lParam));
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETFLAGS:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].Flags() : 0;
+ case Message::IndicGetFlags:
+ return (wParam <= IndicatorMax) ?
+ static_cast<sptr_t>(vs.indicators[wParam].Flags()) : 0;
- case SCI_INDICSETUNDER:
- if (wParam <= INDICATOR_MAX) {
+ case Message::IndicSetUnder:
+ if (wParam <= IndicatorMax) {
vs.indicators[wParam].under = lParam != 0;
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETUNDER:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].under : 0;
+ case Message::IndicGetUnder:
+ return (wParam <= IndicatorMax) ?
+ vs.indicators[wParam].under : 0;
- case SCI_INDICSETALPHA:
- if (wParam <= INDICATOR_MAX && lParam >=0 && lParam <= 255) {
+ case Message::IndicSetAlpha:
+ if (wParam <= IndicatorMax && lParam >=0 && lParam <= 255) {
vs.indicators[wParam].fillAlpha = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETALPHA:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].fillAlpha : 0;
+ case Message::IndicGetAlpha:
+ return (wParam <= IndicatorMax)
+ ? vs.indicators[wParam].fillAlpha : 0;
- case SCI_INDICSETOUTLINEALPHA:
- if (wParam <= INDICATOR_MAX && lParam >=0 && lParam <= 255) {
+ case Message::IndicSetOutlineAlpha:
+ if (wParam <= IndicatorMax && lParam >=0 && lParam <= 255) {
vs.indicators[wParam].outlineAlpha = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETOUTLINEALPHA:
- return (wParam <= INDICATOR_MAX) ? vs.indicators[wParam].outlineAlpha : 0;
+ case Message::IndicGetOutlineAlpha:
+ return (wParam <= IndicatorMax) ? vs.indicators[wParam].outlineAlpha : 0;
- case SCI_INDICSETSTROKEWIDTH:
- if (wParam <= INDICATOR_MAX && lParam >= 0 && lParam <= 1000) {
+ case Message::IndicSetStrokeWidth:
+ if (wParam <= IndicatorMax && lParam >= 0 && lParam <= 1000) {
vs.indicators[wParam].strokeWidth = lParam / 100.0f;
InvalidateStyleRedraw();
}
break;
- case SCI_INDICGETSTROKEWIDTH:
- if (wParam <= INDICATOR_MAX) {
+ case Message::IndicGetStrokeWidth:
+ if (wParam <= IndicatorMax) {
return std::lround(vs.indicators[wParam].strokeWidth * 100);
}
break;
- case SCI_SETINDICATORCURRENT:
+ case Message::SetIndicatorCurrent:
pdoc->DecorationSetCurrentIndicator(static_cast<int>(wParam));
break;
- case SCI_GETINDICATORCURRENT:
+ case Message::GetIndicatorCurrent:
return pdoc->decorations->GetCurrentIndicator();
- case SCI_SETINDICATORVALUE:
+ case Message::SetIndicatorValue:
pdoc->decorations->SetCurrentValue(static_cast<int>(wParam));
break;
- case SCI_GETINDICATORVALUE:
+ case Message::GetIndicatorValue:
return pdoc->decorations->GetCurrentValue();
- case SCI_INDICATORFILLRANGE:
+ case Message::IndicatorFillRange:
pdoc->DecorationFillRange(static_cast<Sci::Position>(wParam),
pdoc->decorations->GetCurrentValue(), lParam);
break;
- case SCI_INDICATORCLEARRANGE:
+ case Message::IndicatorClearRange:
pdoc->DecorationFillRange(static_cast<Sci::Position>(wParam), 0,
lParam);
break;
- case SCI_INDICATORALLONFOR:
+ case Message::IndicatorAllOnFor:
return pdoc->decorations->AllOnFor(static_cast<Sci::Position>(wParam));
- case SCI_INDICATORVALUEAT:
+ case Message::IndicatorValueAt:
return pdoc->decorations->ValueAt(static_cast<int>(wParam), lParam);
- case SCI_INDICATORSTART:
+ case Message::IndicatorStart:
return pdoc->decorations->Start(static_cast<int>(wParam), lParam);
- case SCI_INDICATOREND:
+ case Message::IndicatorEnd:
return pdoc->decorations->End(static_cast<int>(wParam), lParam);
- case SCI_LINEDOWN:
- case SCI_LINEDOWNEXTEND:
- case SCI_PARADOWN:
- case SCI_PARADOWNEXTEND:
- case SCI_LINEUP:
- case SCI_LINEUPEXTEND:
- case SCI_PARAUP:
- case SCI_PARAUPEXTEND:
- case SCI_CHARLEFT:
- case SCI_CHARLEFTEXTEND:
- case SCI_CHARRIGHT:
- case SCI_CHARRIGHTEXTEND:
- case SCI_WORDLEFT:
- case SCI_WORDLEFTEXTEND:
- case SCI_WORDRIGHT:
- case SCI_WORDRIGHTEXTEND:
- case SCI_WORDLEFTEND:
- case SCI_WORDLEFTENDEXTEND:
- case SCI_WORDRIGHTEND:
- case SCI_WORDRIGHTENDEXTEND:
- case SCI_HOME:
- case SCI_HOMEEXTEND:
- case SCI_LINEEND:
- case SCI_LINEENDEXTEND:
- case SCI_HOMEWRAP:
- case SCI_HOMEWRAPEXTEND:
- case SCI_LINEENDWRAP:
- case SCI_LINEENDWRAPEXTEND:
- case SCI_DOCUMENTSTART:
- case SCI_DOCUMENTSTARTEXTEND:
- case SCI_DOCUMENTEND:
- case SCI_DOCUMENTENDEXTEND:
- case SCI_SCROLLTOSTART:
- case SCI_SCROLLTOEND:
-
- case SCI_STUTTEREDPAGEUP:
- case SCI_STUTTEREDPAGEUPEXTEND:
- case SCI_STUTTEREDPAGEDOWN:
- case SCI_STUTTEREDPAGEDOWNEXTEND:
-
- case SCI_PAGEUP:
- case SCI_PAGEUPEXTEND:
- case SCI_PAGEDOWN:
- case SCI_PAGEDOWNEXTEND:
- case SCI_EDITTOGGLEOVERTYPE:
- case SCI_CANCEL:
- case SCI_DELETEBACK:
- case SCI_TAB:
- case SCI_BACKTAB:
- case SCI_NEWLINE:
- case SCI_FORMFEED:
- case SCI_VCHOME:
- case SCI_VCHOMEEXTEND:
- case SCI_VCHOMEWRAP:
- case SCI_VCHOMEWRAPEXTEND:
- case SCI_VCHOMEDISPLAY:
- case SCI_VCHOMEDISPLAYEXTEND:
- case SCI_ZOOMIN:
- case SCI_ZOOMOUT:
- case SCI_DELWORDLEFT:
- case SCI_DELWORDRIGHT:
- case SCI_DELWORDRIGHTEND:
- case SCI_DELLINELEFT:
- case SCI_DELLINERIGHT:
- case SCI_LINECOPY:
- case SCI_LINECUT:
- case SCI_LINEDELETE:
- case SCI_LINETRANSPOSE:
- case SCI_LINEREVERSE:
- case SCI_LINEDUPLICATE:
- case SCI_LOWERCASE:
- case SCI_UPPERCASE:
- case SCI_LINESCROLLDOWN:
- case SCI_LINESCROLLUP:
- case SCI_WORDPARTLEFT:
- case SCI_WORDPARTLEFTEXTEND:
- case SCI_WORDPARTRIGHT:
- case SCI_WORDPARTRIGHTEXTEND:
- case SCI_DELETEBACKNOTLINE:
- case SCI_HOMEDISPLAY:
- case SCI_HOMEDISPLAYEXTEND:
- case SCI_LINEENDDISPLAY:
- case SCI_LINEENDDISPLAYEXTEND:
- case SCI_LINEDOWNRECTEXTEND:
- case SCI_LINEUPRECTEXTEND:
- case SCI_CHARLEFTRECTEXTEND:
- case SCI_CHARRIGHTRECTEXTEND:
- case SCI_HOMERECTEXTEND:
- case SCI_VCHOMERECTEXTEND:
- case SCI_LINEENDRECTEXTEND:
- case SCI_PAGEUPRECTEXTEND:
- case SCI_PAGEDOWNRECTEXTEND:
- case SCI_SELECTIONDUPLICATE:
+ case Message::LineDown:
+ case Message::LineDownExtend:
+ case Message::ParaDown:
+ case Message::ParaDownExtend:
+ case Message::LineUp:
+ case Message::LineUpExtend:
+ case Message::ParaUp:
+ case Message::ParaUpExtend:
+ case Message::CharLeft:
+ case Message::CharLeftExtend:
+ case Message::CharRight:
+ case Message::CharRightExtend:
+ case Message::WordLeft:
+ case Message::WordLeftExtend:
+ case Message::WordRight:
+ case Message::WordRightExtend:
+ case Message::WordLeftEnd:
+ case Message::WordLeftEndExtend:
+ case Message::WordRightEnd:
+ case Message::WordRightEndExtend:
+ case Message::Home:
+ case Message::HomeExtend:
+ case Message::LineEnd:
+ case Message::LineEndExtend:
+ case Message::HomeWrap:
+ case Message::HomeWrapExtend:
+ case Message::LineEndWrap:
+ case Message::LineEndWrapExtend:
+ case Message::DocumentStart:
+ case Message::DocumentStartExtend:
+ case Message::DocumentEnd:
+ case Message::DocumentEndExtend:
+ case Message::ScrollToStart:
+ case Message::ScrollToEnd:
+
+ case Message::StutteredPageUp:
+ case Message::StutteredPageUpExtend:
+ case Message::StutteredPageDown:
+ case Message::StutteredPageDownExtend:
+
+ case Message::PageUp:
+ case Message::PageUpExtend:
+ case Message::PageDown:
+ case Message::PageDownExtend:
+ case Message::EditToggleOvertype:
+ case Message::Cancel:
+ case Message::DeleteBack:
+ case Message::Tab:
+ case Message::BackTab:
+ case Message::NewLine:
+ case Message::FormFeed:
+ case Message::VCHome:
+ case Message::VCHomeExtend:
+ case Message::VCHomeWrap:
+ case Message::VCHomeWrapExtend:
+ case Message::VCHomeDisplay:
+ case Message::VCHomeDisplayExtend:
+ case Message::ZoomIn:
+ case Message::ZoomOut:
+ case Message::DelWordLeft:
+ case Message::DelWordRight:
+ case Message::DelWordRightEnd:
+ case Message::DelLineLeft:
+ case Message::DelLineRight:
+ case Message::LineCopy:
+ case Message::LineCut:
+ case Message::LineDelete:
+ case Message::LineTranspose:
+ case Message::LineReverse:
+ case Message::LineDuplicate:
+ case Message::LowerCase:
+ case Message::UpperCase:
+ case Message::LineScrollDown:
+ case Message::LineScrollUp:
+ case Message::WordPartLeft:
+ case Message::WordPartLeftExtend:
+ case Message::WordPartRight:
+ case Message::WordPartRightExtend:
+ case Message::DeleteBackNotLine:
+ case Message::HomeDisplay:
+ case Message::HomeDisplayExtend:
+ case Message::LineEndDisplay:
+ case Message::LineEndDisplayExtend:
+ case Message::LineDownRectExtend:
+ case Message::LineUpRectExtend:
+ case Message::CharLeftRectExtend:
+ case Message::CharRightRectExtend:
+ case Message::HomeRectExtend:
+ case Message::VCHomeRectExtend:
+ case Message::LineEndRectExtend:
+ case Message::PageUpRectExtend:
+ case Message::PageDownRectExtend:
+ case Message::SelectionDuplicate:
return KeyCommand(iMessage);
- case SCI_BRACEHIGHLIGHT:
- SetBraceHighlight(static_cast<Sci::Position>(wParam), lParam, STYLE_BRACELIGHT);
+ case Message::BraceHighlight:
+ SetBraceHighlight(static_cast<Sci::Position>(wParam), lParam, StyleBraceLight);
break;
- case SCI_BRACEHIGHLIGHTINDICATOR:
- if (lParam >= 0 && lParam <= INDICATOR_MAX) {
+ case Message::BraceHighlightIndicator:
+ if (lParam >= 0 && static_cast<size_t>(lParam) <= IndicatorMax) {
vs.braceHighlightIndicatorSet = wParam != 0;
vs.braceHighlightIndicator = static_cast<int>(lParam);
}
break;
- case SCI_BRACEBADLIGHT:
- SetBraceHighlight(static_cast<Sci::Position>(wParam), -1, STYLE_BRACEBAD);
+ case Message::BraceBadLight:
+ SetBraceHighlight(static_cast<Sci::Position>(wParam), -1, StyleBraceBad);
break;
- case SCI_BRACEBADLIGHTINDICATOR:
- if (lParam >= 0 && lParam <= INDICATOR_MAX) {
+ case Message::BraceBadLightIndicator:
+ if (lParam >= 0 && static_cast<size_t>(lParam) <= IndicatorMax) {
vs.braceBadLightIndicatorSet = wParam != 0;
vs.braceBadLightIndicator = static_cast<int>(lParam);
}
break;
- case SCI_BRACEMATCH:
+ case Message::BraceMatch:
// wParam is position of char to find brace for,
// lParam is maximum amount of text to restyle to find it
return pdoc->BraceMatch(static_cast<Sci::Position>(wParam), lParam, 0, false);
- case SCI_BRACEMATCHNEXT:
+ case Message::BraceMatchNext:
return pdoc->BraceMatch(static_cast<Sci::Position>(wParam), 0, lParam, true);
- case SCI_GETVIEWEOL:
+ case Message::GetViewEOL:
return vs.viewEOL;
- case SCI_SETVIEWEOL:
+ case Message::SetViewEOL:
vs.viewEOL = wParam != 0;
InvalidateStyleRedraw();
break;
- case SCI_SETZOOM: {
+ case Message::SetZoom: {
const int zoomLevel = static_cast<int>(wParam);
if (zoomLevel != vs.zoomLevel) {
vs.zoomLevel = zoomLevel;
@@ -7854,44 +7873,44 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
}
- case SCI_GETZOOM:
+ case Message::GetZoom:
return vs.zoomLevel;
- case SCI_GETEDGECOLUMN:
+ case Message::GetEdgeColumn:
return vs.theEdge.column;
- case SCI_SETEDGECOLUMN:
+ case Message::SetEdgeColumn:
vs.theEdge.column = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_GETEDGEMODE:
- return vs.edgeState;
+ case Message::GetEdgeMode:
+ return static_cast<sptr_t>(vs.edgeState);
- case SCI_SETEDGEMODE:
- vs.edgeState = static_cast<int>(wParam);
+ case Message::SetEdgeMode:
+ vs.edgeState = static_cast<EdgeVisualStyle>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_GETEDGECOLOUR:
+ case Message::GetEdgeColour:
return vs.theEdge.colour.OpaqueRGB();
- case SCI_SETEDGECOLOUR:
+ case Message::SetEdgeColour:
vs.theEdge.colour = ColourRGBA::FromRGB(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_MULTIEDGEADDLINE:
+ case Message::MultiEdgeAddLine:
vs.AddMultiEdge(wParam, lParam);
InvalidateStyleRedraw();
break;
- case SCI_MULTIEDGECLEARALL:
+ case Message::MultiEdgeClearAll:
std::vector<EdgeProperties>().swap(vs.theMultiEdge); // Free vector and memory, C++03 compatible
InvalidateStyleRedraw();
break;
- case SCI_GETMULTIEDGECOLUMN: {
+ case Message::GetMultiEdgeColumn: {
const size_t which = wParam;
// size_t is unsigned so this also handles negative inputs.
if (which >= vs.theMultiEdge.size()) {
@@ -7900,42 +7919,42 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.theMultiEdge[which].column;
}
- case SCI_GETACCESSIBILITY:
- return SC_ACCESSIBILITY_DISABLED;
+ case Message::GetAccessibility:
+ return static_cast<sptr_t>(Accessibility::Disabled);
- case SCI_SETACCESSIBILITY:
+ case Message::SetAccessibility:
// May be implemented by platform code.
break;
- case SCI_GETDOCPOINTER:
+ case Message::GetDocPointer:
return reinterpret_cast<sptr_t>(pdoc);
- case SCI_SETDOCPOINTER:
+ case Message::SetDocPointer:
CancelModes();
SetDocPointer(static_cast<Document *>(PtrFromSPtr(lParam)));
return 0;
- case SCI_CREATEDOCUMENT: {
- Document *doc = new Document(static_cast<int>(lParam));
+ case Message::CreateDocument: {
+ Document *doc = new Document(static_cast<DocumentOption>(lParam));
doc->AddRef();
doc->Allocate(static_cast<Sci::Position>(wParam));
pcs = ContractionStateCreate(pdoc->IsLarge());
return reinterpret_cast<sptr_t>(doc);
}
- case SCI_ADDREFDOCUMENT:
+ case Message::AddRefDocument:
(static_cast<Document *>(PtrFromSPtr(lParam)))->AddRef();
break;
- case SCI_RELEASEDOCUMENT:
+ case Message::ReleaseDocument:
(static_cast<Document *>(PtrFromSPtr(lParam)))->Release();
break;
- case SCI_GETDOCUMENTOPTIONS:
- return pdoc->Options();
+ case Message::GetDocumentOptions:
+ return static_cast<sptr_t>(pdoc->Options());
- case SCI_CREATELOADER: {
- Document *doc = new Document(static_cast<int>(lParam));
+ case Message::CreateLoader: {
+ Document *doc = new Document(static_cast<DocumentOption>(lParam));
doc->AddRef();
doc->Allocate(static_cast<Sci::Position>(wParam));
doc->SetUndoCollection(false);
@@ -7943,49 +7962,49 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc));
}
- case SCI_SETMODEVENTMASK:
- modEventMask = static_cast<int>(wParam);
+ case Message::SetModEventMask:
+ modEventMask = static_cast<ModificationFlags>(wParam);
return 0;
- case SCI_GETMODEVENTMASK:
- return modEventMask;
+ case Message::GetModEventMask:
+ return static_cast<sptr_t>(modEventMask);
- case SCI_SETCOMMANDEVENTS:
+ case Message::SetCommandEvents:
commandEvents = static_cast<bool>(wParam);
return 0;
- case SCI_GETCOMMANDEVENTS:
+ case Message::GetCommandEvents:
return commandEvents;
- case SCI_CONVERTEOLS:
- pdoc->ConvertLineEnds(static_cast<int>(wParam));
+ case Message::ConvertEOLs:
+ pdoc->ConvertLineEnds(static_cast<EndOfLine>(wParam));
SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document
return 0;
- case SCI_SETLENGTHFORENCODE:
+ case Message::SetLengthForEncode:
lengthForEncode = static_cast<Sci::Position>(wParam);
return 0;
- case SCI_SELECTIONISRECTANGLE:
+ case Message::SelectionIsRectangle:
return sel.selType == Selection::SelTypes::rectangle ? 1 : 0;
- case SCI_SETSELECTIONMODE: {
- switch (wParam) {
- case SC_SEL_STREAM:
+ case Message::SetSelectionMode: {
+ switch (static_cast<SelectionMode>(wParam)) {
+ case SelectionMode::Stream:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::stream));
sel.selType = Selection::SelTypes::stream;
break;
- case SC_SEL_RECTANGLE:
+ case SelectionMode::Rectangle:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::rectangle));
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular() = sel.RangeMain(); // adjust current selection
break;
- case SC_SEL_LINES:
+ case SelectionMode::Lines:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::lines));
sel.selType = Selection::SelTypes::lines;
SetSelection(sel.RangeMain().caret, sel.RangeMain().anchor); // adjust current selection
break;
- case SC_SEL_THIN:
+ case SelectionMode::Thin:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::thin));
sel.selType = Selection::SelTypes::thin;
break;
@@ -7996,96 +8015,96 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
InvalidateWholeSelection();
break;
}
- case SCI_GETSELECTIONMODE:
+ case Message::GetSelectionMode:
switch (sel.selType) {
case Selection::SelTypes::stream:
- return SC_SEL_STREAM;
+ return static_cast<sptr_t>(SelectionMode::Stream);
case Selection::SelTypes::rectangle:
- return SC_SEL_RECTANGLE;
+ return static_cast<sptr_t>(SelectionMode::Rectangle);
case Selection::SelTypes::lines:
- return SC_SEL_LINES;
+ return static_cast<sptr_t>(SelectionMode::Lines);
case Selection::SelTypes::thin:
- return SC_SEL_THIN;
+ return static_cast<sptr_t>(SelectionMode::Thin);
default: // ?!
- return SC_SEL_STREAM;
+ return static_cast<sptr_t>(SelectionMode::Stream);
}
- case SCI_GETMOVEEXTENDSSELECTION:
+ case Message::GetMoveExtendsSelection:
return sel.MoveExtends();
- case SCI_GETLINESELSTARTPOSITION:
- case SCI_GETLINESELENDPOSITION: {
+ case Message::GetLineSelStartPosition:
+ case Message::GetLineSelEndPosition: {
const SelectionSegment segmentLine(
SelectionPosition(pdoc->LineStart(static_cast<Sci::Position>(wParam))),
SelectionPosition(pdoc->LineEnd(static_cast<Sci::Position>(wParam))));
for (size_t r=0; r<sel.Count(); r++) {
const SelectionSegment portion = sel.Range(r).Intersect(segmentLine);
if (portion.start.IsValid()) {
- return (iMessage == SCI_GETLINESELSTARTPOSITION) ? portion.start.Position() : portion.end.Position();
+ return (iMessage == Message::GetLineSelStartPosition) ? portion.start.Position() : portion.end.Position();
}
}
return Sci::invalidPosition;
}
- case SCI_SETOVERTYPE:
+ case Message::SetOvertype:
if (inOverstrike != (wParam != 0)) {
inOverstrike = wParam != 0;
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
ShowCaretAtCurrentPosition();
SetIdle(true);
}
break;
- case SCI_GETOVERTYPE:
+ case Message::GetOvertype:
return inOverstrike ? 1 : 0;
- case SCI_SETFOCUS:
+ case Message::SetFocus:
SetFocusState(wParam != 0);
break;
- case SCI_GETFOCUS:
+ case Message::GetFocus:
return hasFocus;
- case SCI_SETSTATUS:
- errorStatus = static_cast<int>(wParam);
+ case Message::SetStatus:
+ errorStatus = static_cast<Status>(wParam);
break;
- case SCI_GETSTATUS:
- return errorStatus;
+ case Message::GetStatus:
+ return static_cast<sptr_t>(errorStatus);
- case SCI_SETMOUSEDOWNCAPTURES:
+ case Message::SetMouseDownCaptures:
mouseDownCaptures = wParam != 0;
break;
- case SCI_GETMOUSEDOWNCAPTURES:
+ case Message::GetMouseDownCaptures:
return mouseDownCaptures;
- case SCI_SETMOUSEWHEELCAPTURES:
+ case Message::SetMouseWheelCaptures:
mouseWheelCaptures = wParam != 0;
break;
- case SCI_GETMOUSEWHEELCAPTURES:
+ case Message::GetMouseWheelCaptures:
return mouseWheelCaptures;
- case SCI_SETCURSOR:
- cursorMode = static_cast<int>(wParam);
+ case Message::SetCursor:
+ cursorMode = static_cast<CursorShape>(wParam);
DisplayCursor(Window::Cursor::text);
break;
- case SCI_GETCURSOR:
- return cursorMode;
+ case Message::GetCursor:
+ return static_cast<sptr_t>(cursorMode);
- case SCI_SETCONTROLCHARSYMBOL:
+ case Message::SetControlCharSymbol:
vs.controlCharSymbol = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_GETCONTROLCHARSYMBOL:
+ case Message::GetControlCharSymbol:
return vs.controlCharSymbol;
- case SCI_SETREPRESENTATION:
+ case Message::SetRepresentation:
reprs.SetRepresentation(ConstCharPtrFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
- case SCI_GETREPRESENTATION: {
+ case Message::GetRepresentation: {
const Representation *repr = reprs.RepresentationFromCharacter(
ConstCharPtrFromUPtr(wParam), UTF8MaxBytes);
if (repr) {
@@ -8094,363 +8113,364 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return 0;
}
- case SCI_CLEARREPRESENTATION:
+ case Message::ClearRepresentation:
reprs.ClearRepresentation(ConstCharPtrFromUPtr(wParam));
break;
- case SCI_STARTRECORD:
+ case Message::StartRecord:
recordingMacro = true;
return 0;
- case SCI_STOPRECORD:
+ case Message::StopRecord:
recordingMacro = false;
return 0;
- case SCI_MOVECARETINSIDEVIEW:
+ case Message::MoveCaretInsideView:
MoveCaretInsideView();
break;
- case SCI_SETFOLDMARGINCOLOUR:
+ case Message::SetFoldMarginColour:
vs.foldmarginColour = OptionalColour(wParam, lParam);
InvalidateStyleRedraw();
break;
- case SCI_SETFOLDMARGINHICOLOUR:
+ case Message::SetFoldMarginHiColour:
vs.foldmarginHighlightColour = OptionalColour(wParam, lParam);
InvalidateStyleRedraw();
break;
- case SCI_SETHOTSPOTACTIVEFORE:
- if (vs.SetElementColourOptional(SC_ELEMENT_HOT_SPOT_ACTIVE, wParam, lParam)) {
+ case Message::SetHotspotActiveFore:
+ if (vs.SetElementColourOptional(Element::HotSpotActive, wParam, lParam)) {
InvalidateStyleRedraw();
}
break;
- case SCI_GETHOTSPOTACTIVEFORE:
- return vs.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE).value_or(ColourRGBA()).OpaqueRGB();
+ case Message::GetHotspotActiveFore:
+ return vs.ElementColour(Element::HotSpotActive).value_or(ColourRGBA()).OpaqueRGB();
- case SCI_SETHOTSPOTACTIVEBACK:
- if (vs.SetElementColourOptional(SC_ELEMENT_HOT_SPOT_ACTIVE_BACK, wParam, lParam)) {
+ case Message::SetHotspotActiveBack:
+ if (vs.SetElementColourOptional(Element::HotSpotActiveBack, wParam, lParam)) {
InvalidateStyleRedraw();
}
break;
- case SCI_GETHOTSPOTACTIVEBACK:
- return vs.ElementColour(SC_ELEMENT_HOT_SPOT_ACTIVE_BACK).value_or(ColourRGBA()).OpaqueRGB();
+ case Message::GetHotspotActiveBack:
+ return vs.ElementColour(Element::HotSpotActiveBack).value_or(ColourRGBA()).OpaqueRGB();
- case SCI_SETHOTSPOTACTIVEUNDERLINE:
+ case Message::SetHotspotActiveUnderline:
vs.hotspotUnderline = wParam != 0;
InvalidateStyleRedraw();
break;
- case SCI_GETHOTSPOTACTIVEUNDERLINE:
+ case Message::GetHotspotActiveUnderline:
return vs.hotspotUnderline ? 1 : 0;
- case SCI_SETHOTSPOTSINGLELINE:
+ case Message::SetHotspotSingleLine:
hotspotSingleLine = wParam != 0;
InvalidateStyleRedraw();
break;
- case SCI_GETHOTSPOTSINGLELINE:
+ case Message::GetHotspotSingleLine:
return hotspotSingleLine ? 1 : 0;
- case SCI_SETPASTECONVERTENDINGS:
+ case Message::SetPasteConvertEndings:
convertPastes = wParam != 0;
break;
- case SCI_GETPASTECONVERTENDINGS:
+ case Message::GetPasteConvertEndings:
return convertPastes ? 1 : 0;
- case SCI_GETCHARACTERPOINTER:
+ case Message::GetCharacterPointer:
return reinterpret_cast<sptr_t>(pdoc->BufferPointer());
- case SCI_GETRANGEPOINTER:
+ case Message::GetRangePointer:
return reinterpret_cast<sptr_t>(pdoc->RangePointer(
static_cast<Sci::Position>(wParam), lParam));
- case SCI_GETGAPPOSITION:
+ case Message::GetGapPosition:
return pdoc->GapPosition();
- case SCI_SETEXTRAASCENT:
+ case Message::SetExtraAscent:
vs.extraAscent = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_GETEXTRAASCENT:
+ case Message::GetExtraAscent:
return vs.extraAscent;
- case SCI_SETEXTRADESCENT:
+ case Message::SetExtraDescent:
vs.extraDescent = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_GETEXTRADESCENT:
+ case Message::GetExtraDescent:
return vs.extraDescent;
- case SCI_MARGINSETSTYLEOFFSET:
+ case Message::MarginSetStyleOffset:
vs.marginStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_MARGINGETSTYLEOFFSET:
+ case Message::MarginGetStyleOffset:
return vs.marginStyleOffset;
- case SCI_SETMARGINOPTIONS:
- marginOptions = static_cast<int>(wParam);
+ case Message::SetMarginOptions:
+ marginOptions = static_cast<MarginOption>(wParam);
break;
- case SCI_GETMARGINOPTIONS:
- return marginOptions;
+ case Message::GetMarginOptions:
+ return static_cast<sptr_t>(marginOptions);
- case SCI_MARGINSETTEXT:
+ case Message::MarginSetText:
pdoc->MarginSetText(static_cast<Sci::Line>(wParam), CharPtrFromSPtr(lParam));
break;
- case SCI_MARGINGETTEXT: {
+ case Message::MarginGetText: {
const StyledText st = pdoc->MarginStyledText(static_cast<Sci::Line>(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
- case SCI_MARGINSETSTYLE:
+ case Message::MarginSetStyle:
pdoc->MarginSetStyle(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
break;
- case SCI_MARGINGETSTYLE: {
+ case Message::MarginGetStyle: {
const StyledText st = pdoc->MarginStyledText(static_cast<Sci::Line>(wParam));
return st.style;
}
- case SCI_MARGINSETSTYLES:
+ case Message::MarginSetStyles:
pdoc->MarginSetStyles(static_cast<Sci::Line>(wParam), ConstUCharPtrFromSPtr(lParam));
break;
- case SCI_MARGINGETSTYLES: {
+ case Message::MarginGetStyles: {
const StyledText st = pdoc->MarginStyledText(static_cast<Sci::Line>(wParam));
return BytesResult(lParam, st.styles, st.length);
}
- case SCI_MARGINTEXTCLEARALL:
+ case Message::MarginTextClearAll:
pdoc->MarginClearAll();
break;
- case SCI_ANNOTATIONSETTEXT:
+ case Message::AnnotationSetText:
pdoc->AnnotationSetText(static_cast<Sci::Line>(wParam), CharPtrFromSPtr(lParam));
break;
- case SCI_ANNOTATIONGETTEXT: {
+ case Message::AnnotationGetText: {
const StyledText st = pdoc->AnnotationStyledText(static_cast<Sci::Line>(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
- case SCI_ANNOTATIONGETSTYLE: {
+ case Message::AnnotationGetStyle: {
const StyledText st = pdoc->AnnotationStyledText(static_cast<Sci::Line>(wParam));
return st.style;
}
- case SCI_ANNOTATIONSETSTYLE:
+ case Message::AnnotationSetStyle:
pdoc->AnnotationSetStyle(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
break;
- case SCI_ANNOTATIONSETSTYLES:
+ case Message::AnnotationSetStyles:
pdoc->AnnotationSetStyles(static_cast<Sci::Line>(wParam), ConstUCharPtrFromSPtr(lParam));
break;
- case SCI_ANNOTATIONGETSTYLES: {
+ case Message::AnnotationGetStyles: {
const StyledText st = pdoc->AnnotationStyledText(static_cast<Sci::Line>(wParam));
return BytesResult(lParam, st.styles, st.length);
}
- case SCI_ANNOTATIONGETLINES:
+ case Message::AnnotationGetLines:
return pdoc->AnnotationLines(static_cast<Sci::Line>(wParam));
- case SCI_ANNOTATIONCLEARALL:
+ case Message::AnnotationClearAll:
pdoc->AnnotationClearAll();
break;
- case SCI_ANNOTATIONSETVISIBLE:
- SetAnnotationVisible(static_cast<int>(wParam));
+ case Message::AnnotationSetVisible:
+ SetAnnotationVisible(static_cast<AnnotationVisible>(wParam));
break;
- case SCI_ANNOTATIONGETVISIBLE:
- return vs.annotationVisible;
+ case Message::AnnotationGetVisible:
+ return static_cast<sptr_t>(vs.annotationVisible);
- case SCI_ANNOTATIONSETSTYLEOFFSET:
+ case Message::AnnotationSetStyleOffset:
vs.annotationStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_ANNOTATIONGETSTYLEOFFSET:
+ case Message::AnnotationGetStyleOffset:
return vs.annotationStyleOffset;
- case SCI_EOLANNOTATIONSETTEXT:
+ case Message::EOLAnnotationSetText:
pdoc->EOLAnnotationSetText(static_cast<Sci::Line>(wParam), CharPtrFromSPtr(lParam));
break;
- case SCI_EOLANNOTATIONGETTEXT: {
+ case Message::EOLAnnotationGetText: {
const StyledText st = pdoc->EOLAnnotationStyledText(static_cast<Sci::Line>(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
- case SCI_EOLANNOTATIONGETSTYLE: {
+ case Message::EOLAnnotationGetStyle: {
const StyledText st = pdoc->EOLAnnotationStyledText(static_cast<Sci::Line>(wParam));
return st.style;
}
- case SCI_EOLANNOTATIONSETSTYLE:
+ case Message::EOLAnnotationSetStyle:
pdoc->EOLAnnotationSetStyle(static_cast<Sci::Line>(wParam), static_cast<int>(lParam));
break;
- case SCI_EOLANNOTATIONCLEARALL:
+ case Message::EOLAnnotationClearAll:
pdoc->EOLAnnotationClearAll();
break;
- case SCI_EOLANNOTATIONSETVISIBLE:
- SetEOLAnnotationVisible(static_cast<int>(wParam));
+ case Message::EOLAnnotationSetVisible:
+ SetEOLAnnotationVisible(static_cast<EOLAnnotationVisible>(wParam));
break;
- case SCI_EOLANNOTATIONGETVISIBLE:
- return vs.eolAnnotationVisible;
+ case Message::EOLAnnotationGetVisible:
+ return static_cast<sptr_t>(vs.eolAnnotationVisible);
- case SCI_EOLANNOTATIONSETSTYLEOFFSET:
+ case Message::EOLAnnotationSetStyleOffset:
vs.eolAnnotationStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
- case SCI_EOLANNOTATIONGETSTYLEOFFSET:
+ case Message::EOLAnnotationGetStyleOffset:
return vs.eolAnnotationStyleOffset;
- case SCI_RELEASEALLEXTENDEDSTYLES:
+ case Message::ReleaseAllExtendedStyles:
vs.ReleaseAllExtendedStyles();
break;
- case SCI_ALLOCATEEXTENDEDSTYLES:
+ case Message::AllocateExtendedStyles:
return vs.AllocateExtendedStyles(static_cast<int>(wParam));
- case SCI_SUPPORTSFEATURE:
- return SupportsFeature(static_cast<int>(wParam));
+ case Message::SupportsFeature:
+ return SupportsFeature(static_cast<Supports>(wParam));
- case SCI_ADDUNDOACTION:
- pdoc->AddUndoAction(static_cast<Sci::Position>(wParam), lParam & UNDO_MAY_COALESCE);
+ case Message::AddUndoAction:
+ pdoc->AddUndoAction(static_cast<Sci::Position>(wParam),
+ FlagSet(static_cast<UndoFlags>(lParam), UndoFlags::MayCoalesce));
break;
- case SCI_SETMOUSESELECTIONRECTANGULARSWITCH:
+ case Message::SetMouseSelectionRectangularSwitch:
mouseSelectionRectangularSwitch = wParam != 0;
break;
- case SCI_GETMOUSESELECTIONRECTANGULARSWITCH:
+ case Message::GetMouseSelectionRectangularSwitch:
return mouseSelectionRectangularSwitch;
- case SCI_SETMULTIPLESELECTION:
+ case Message::SetMultipleSelection:
multipleSelection = wParam != 0;
InvalidateCaret();
break;
- case SCI_GETMULTIPLESELECTION:
+ case Message::GetMultipleSelection:
return multipleSelection;
- case SCI_SETADDITIONALSELECTIONTYPING:
+ case Message::SetAdditionalSelectionTyping:
additionalSelectionTyping = wParam != 0;
InvalidateCaret();
break;
- case SCI_GETADDITIONALSELECTIONTYPING:
+ case Message::GetAdditionalSelectionTyping:
return additionalSelectionTyping;
- case SCI_SETMULTIPASTE:
- multiPasteMode = static_cast<int>(wParam);
+ case Message::SetMultiPaste:
+ multiPasteMode = static_cast<MultiPaste>(wParam);
break;
- case SCI_GETMULTIPASTE:
- return multiPasteMode;
+ case Message::GetMultiPaste:
+ return static_cast<sptr_t>(multiPasteMode);
- case SCI_SETADDITIONALCARETSBLINK:
+ case Message::SetAdditionalCaretsBlink:
view.additionalCaretsBlink = wParam != 0;
InvalidateCaret();
break;
- case SCI_GETADDITIONALCARETSBLINK:
+ case Message::GetAdditionalCaretsBlink:
return view.additionalCaretsBlink;
- case SCI_SETADDITIONALCARETSVISIBLE:
+ case Message::SetAdditionalCaretsVisible:
view.additionalCaretsVisible = wParam != 0;
InvalidateCaret();
break;
- case SCI_GETADDITIONALCARETSVISIBLE:
+ case Message::GetAdditionalCaretsVisible:
return view.additionalCaretsVisible;
- case SCI_GETSELECTIONS:
+ case Message::GetSelections:
return sel.Count();
- case SCI_GETSELECTIONEMPTY:
+ case Message::GetSelectionEmpty:
return sel.Empty();
- case SCI_CLEARSELECTIONS:
+ case Message::ClearSelections:
sel.Clear();
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
- case SCI_SETSELECTION:
+ case Message::SetSelection:
sel.SetSelection(SelectionRange(static_cast<Sci::Position>(wParam), lParam));
Redraw();
break;
- case SCI_ADDSELECTION:
+ case Message::AddSelection:
sel.AddSelection(SelectionRange(static_cast<Sci::Position>(wParam), lParam));
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
- case SCI_DROPSELECTIONN:
+ case Message::DropSelectionN:
sel.DropSelection(static_cast<size_t>(wParam));
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
- case SCI_SETMAINSELECTION:
+ case Message::SetMainSelection:
sel.SetMain(static_cast<size_t>(wParam));
- ContainerNeedsUpdate(SC_UPDATE_SELECTION);
+ ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
- case SCI_GETMAINSELECTION:
+ case Message::GetMainSelection:
return sel.Main();
- case SCI_SETSELECTIONNCARET:
- case SCI_SETSELECTIONNANCHOR:
- case SCI_SETSELECTIONNCARETVIRTUALSPACE:
- case SCI_SETSELECTIONNANCHORVIRTUALSPACE:
- case SCI_SETSELECTIONNSTART:
- case SCI_SETSELECTIONNEND:
+ case Message::SetSelectionNCaret:
+ case Message::SetSelectionNAnchor:
+ case Message::SetSelectionNCaretVirtualSpace:
+ case Message::SetSelectionNAnchorVirtualSpace:
+ case Message::SetSelectionNStart:
+ case Message::SetSelectionNEnd:
SetSelectionNMessage(iMessage, wParam, lParam);
break;
- case SCI_GETSELECTIONNCARET:
+ case Message::GetSelectionNCaret:
return sel.Range(wParam).caret.Position();
- case SCI_GETSELECTIONNANCHOR:
+ case Message::GetSelectionNAnchor:
return sel.Range(wParam).anchor.Position();
- case SCI_GETSELECTIONNCARETVIRTUALSPACE:
+ case Message::GetSelectionNCaretVirtualSpace:
return sel.Range(wParam).caret.VirtualSpace();
- case SCI_GETSELECTIONNANCHORVIRTUALSPACE:
+ case Message::GetSelectionNAnchorVirtualSpace:
return sel.Range(wParam).anchor.VirtualSpace();
- case SCI_GETSELECTIONNSTART:
+ case Message::GetSelectionNStart:
return sel.Range(wParam).Start().Position();
- case SCI_GETSELECTIONNSTARTVIRTUALSPACE:
+ case Message::GetSelectionNStartVirtualSpace:
return sel.Range(wParam).Start().VirtualSpace();
- case SCI_GETSELECTIONNEND:
+ case Message::GetSelectionNEnd:
return sel.Range(wParam).End().Position();
- case SCI_GETSELECTIONNENDVIRTUALSPACE:
+ case Message::GetSelectionNEndVirtualSpace:
return sel.Range(wParam).End().VirtualSpace();
- case SCI_SETRECTANGULARSELECTIONCARET:
+ case Message::SetRectangularSelectionCaret:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
@@ -8459,10 +8479,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
Redraw();
break;
- case SCI_GETRECTANGULARSELECTIONCARET:
+ case Message::GetRectangularSelectionCaret:
return sel.Rectangular().caret.Position();
- case SCI_SETRECTANGULARSELECTIONANCHOR:
+ case Message::SetRectangularSelectionAnchor:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
@@ -8471,10 +8491,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
Redraw();
break;
- case SCI_GETRECTANGULARSELECTIONANCHOR:
+ case Message::GetRectangularSelectionAnchor:
return sel.Rectangular().anchor.Position();
- case SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE:
+ case Message::SetRectangularSelectionCaretVirtualSpace:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
@@ -8483,10 +8503,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
Redraw();
break;
- case SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE:
+ case Message::GetRectangularSelectionCaretVirtualSpace:
return sel.Rectangular().caret.VirtualSpace();
- case SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE:
+ case Message::SetRectangularSelectionAnchorVirtualSpace:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
@@ -8495,84 +8515,84 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
Redraw();
break;
- case SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE:
+ case Message::GetRectangularSelectionAnchorVirtualSpace:
return sel.Rectangular().anchor.VirtualSpace();
- case SCI_SETVIRTUALSPACEOPTIONS:
- virtualSpaceOptions = static_cast<int>(wParam);
+ case Message::SetVirtualSpaceOptions:
+ virtualSpaceOptions = static_cast<VirtualSpace>(wParam);
break;
- case SCI_GETVIRTUALSPACEOPTIONS:
- return virtualSpaceOptions;
+ case Message::GetVirtualSpaceOptions:
+ return static_cast<sptr_t>(virtualSpaceOptions);
- case SCI_SETADDITIONALSELFORE:
- vs.elementColours[SC_ELEMENT_SELECTION_ADDITIONAL_TEXT] = ColourRGBA::FromRGB(static_cast<int>(wParam));
+ case Message::SetAdditionalSelFore:
+ vs.elementColours[Element::SelectionAdditionalText] = ColourRGBA::FromRGB(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_SETADDITIONALSELBACK:
- vs.SetElementRGB(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, static_cast<int>(wParam));
+ case Message::SetAdditionalSelBack:
+ vs.SetElementRGB(Element::SelectionAdditionalBack, static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_SETADDITIONALSELALPHA:
- vs.SetElementAlpha(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, static_cast<int>(wParam));
+ case Message::SetAdditionalSelAlpha:
+ vs.SetElementAlpha(Element::SelectionAdditionalBack, static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_GETADDITIONALSELALPHA:
- if (vs.selection.layer == Layer::base)
- return SC_ALPHA_NOALPHA;
- return vs.ElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_BACK)->GetAlpha();
+ case Message::GetAdditionalSelAlpha:
+ if (vs.selection.layer == Layer::Base)
+ return static_cast<sptr_t>(Alpha::NoAlpha);
+ return vs.ElementColour(Element::SelectionAdditionalBack)->GetAlpha();
- case SCI_SETADDITIONALCARETFORE:
- vs.elementColours[SC_ELEMENT_CARET_ADDITIONAL] = ColourRGBA::FromRGB(static_cast<int>(wParam));
+ case Message::SetAdditionalCaretFore:
+ vs.elementColours[Element::CaretAdditional] = ColourRGBA::FromRGB(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_GETADDITIONALCARETFORE:
- return vs.ElementColour(SC_ELEMENT_CARET_ADDITIONAL)->OpaqueRGB();
+ case Message::GetAdditionalCaretFore:
+ return vs.ElementColour(Element::CaretAdditional)->OpaqueRGB();
- case SCI_ROTATESELECTION:
+ case Message::RotateSelection:
sel.RotateMain();
InvalidateWholeSelection();
break;
- case SCI_SWAPMAINANCHORCARET:
+ case Message::SwapMainAnchorCaret:
InvalidateSelection(sel.RangeMain());
sel.RangeMain().Swap();
break;
- case SCI_MULTIPLESELECTADDNEXT:
+ case Message::MultipleSelectAddNext:
MultipleSelectAdd(AddNumber::one);
break;
- case SCI_MULTIPLESELECTADDEACH:
+ case Message::MultipleSelectAddEach:
MultipleSelectAdd(AddNumber::each);
break;
- case SCI_CHANGELEXERSTATE:
+ case Message::ChangeLexerState:
pdoc->ChangeLexerState(static_cast<Sci::Position>(wParam), lParam);
break;
- case SCI_SETIDENTIFIER:
+ case Message::SetIdentifier:
SetCtrlID(static_cast<int>(wParam));
break;
- case SCI_GETIDENTIFIER:
+ case Message::GetIdentifier:
return GetCtrlID();
- case SCI_SETTECHNOLOGY:
+ case Message::SetTechnology:
// No action by default
break;
- case SCI_GETTECHNOLOGY:
- return technology;
+ case Message::GetTechnology:
+ return static_cast<sptr_t>(technology);
- case SCI_COUNTCHARACTERS:
+ case Message::CountCharacters:
return pdoc->CountCharacters(static_cast<Sci::Position>(wParam), lParam);
- case SCI_COUNTCODEUNITS:
+ case Message::CountCodeUnits:
return pdoc->CountUTF16(static_cast<Sci::Position>(wParam), lParam);
default:
diff --git a/src/Editor.h b/src/Editor.h
index 42944929b..08e7d134b 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -8,7 +8,7 @@
#ifndef EDITOR_H
#define EDITOR_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
*/
@@ -55,7 +55,7 @@ public:
upTo = 0;
}
void Need(WorkItems items_, Sci::Position pos) noexcept {
- if (FlagSet(items_, WorkItems::style) && (upTo < pos))
+ if (Scintilla::FlagSet(items_, WorkItems::style) && (upTo < pos))
upTo = pos;
items = static_cast<WorkItems>(static_cast<int>(items) | static_cast<int>(items_));
}
@@ -70,16 +70,16 @@ public:
bool rectangular;
bool lineCopy;
int codePage;
- int characterSet;
- SelectionText() noexcept : rectangular(false), lineCopy(false), codePage(0), characterSet(0) {}
+ Scintilla::CharacterSet characterSet;
+ SelectionText() noexcept : rectangular(false), lineCopy(false), codePage(0), characterSet(Scintilla::CharacterSet::Ansi) {}
void Clear() noexcept {
s.clear();
rectangular = false;
lineCopy = false;
codePage = 0;
- characterSet = 0;
+ characterSet = Scintilla::CharacterSet::Ansi;
}
- void Copy(const std::string &s_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) {
+ void Copy(const std::string &s_, int codePage_, Scintilla::CharacterSet characterSet_, bool rectangular_, bool lineCopy_) {
s = s_;
codePage = codePage_;
characterSet = characterSet_;
@@ -145,16 +145,25 @@ struct WrapPending {
}
};
-struct CaretPolicy {
- int policy; // Combination from CARET_SLOP, CARET_STRICT, CARET_JUMPS, CARET_EVEN
+struct CaretPolicySlop {
+ Scintilla::CaretPolicy policy; // Combination from CaretPolicy::Slop, CaretPolicy::Strict, CaretPolicy::Jumps, CaretPolicy::Even
int slop; // Pixels for X, lines for Y
- CaretPolicy(uptr_t policy_=0, sptr_t slop_=0) noexcept :
- policy(static_cast<int>(policy_)), slop(static_cast<int>(slop_)) {}
+ CaretPolicySlop(Scintilla::CaretPolicy policy_, intptr_t slop_) noexcept :
+ policy(policy_), slop(static_cast<int>(slop_)) {}
+ CaretPolicySlop(uintptr_t policy_=0, intptr_t slop_=0) noexcept :
+ policy(static_cast<Scintilla::CaretPolicy>(policy_)), slop(static_cast<int>(slop_)) {}
};
struct CaretPolicies {
- CaretPolicy x;
- CaretPolicy y;
+ CaretPolicySlop x;
+ CaretPolicySlop y;
+};
+
+struct VisiblePolicySlop {
+ Scintilla::VisiblePolicy policy; // Combination from VisiblePolicy::Slop, VisiblePolicy::Strict
+ int slop; // Pixels for X, lines for Y
+ VisiblePolicySlop(uintptr_t policy_ = 0, intptr_t slop_ = 0) noexcept :
+ policy(static_cast<Scintilla::VisiblePolicy>(policy_)), slop(static_cast<int>(slop_)) {}
};
enum class XYScrollOptions {
@@ -165,6 +174,10 @@ enum class XYScrollOptions {
all = useMargin | vertical | horizontal
};
+constexpr XYScrollOptions operator|(XYScrollOptions a, XYScrollOptions b) noexcept {
+ return static_cast<XYScrollOptions>(static_cast<int>(a) | static_cast<int>(b));
+}
+
/**
*/
class Editor : public EditModel, public DocWatcher {
@@ -179,14 +192,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
* When a style attribute is changed, this cache is flushed. */
bool stylesValid;
ViewStyle vs;
- int technology;
+ Scintilla::Technology technology;
Point sizeRGBAImage;
float scaleRGBAImage;
MarginView marginView;
EditView view;
- int cursorMode;
+ Scintilla::CursorShape cursorMode;
bool mouseDownCaptures;
bool mouseWheelCaptures;
@@ -196,14 +209,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
int scrollWidth;
bool verticalScrollBarVisible;
bool endAtLastLine;
- int caretSticky;
- int marginOptions;
+ Scintilla::CaretSticky caretSticky;
+ Scintilla::MarginOption marginOptions;
bool mouseSelectionRectangularSwitch;
bool multipleSelection;
bool additionalSelectionTyping;
- int multiPasteMode;
+ Scintilla::MultiPaste multiPasteMode;
- int virtualSpaceOptions;
+ Scintilla::VirtualSpace virtualSpaceOptions;
KeyMap kmap;
@@ -232,12 +245,12 @@ protected: // ScintillaBase subclass needs access to much of Editor
Sci::Position wordSelectAnchorEndPos;
Sci::Position wordSelectInitialCaretPos;
SelectionSegment targetRange;
- int searchFlags;
+ Scintilla::FindOption searchFlags;
Sci::Line topLine;
Sci::Position posTopLine;
Sci::Position lengthForEncode;
- int needUpdateUI;
+ Scintilla::Update needUpdateUI;
enum class PaintState { notPainting, painting, abandoned } paintState;
bool paintAbandonedByStyling;
@@ -245,23 +258,23 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool paintingAllText;
bool willRedrawAll;
WorkNeeded workNeeded;
- int idleStyling;
+ Scintilla::IdleStyling idleStyling;
bool needIdleStyling;
- int modEventMask;
+ Scintilla::ModificationFlags modEventMask;
bool commandEvents;
SelectionText drag;
CaretPolicies caretPolicies;
- CaretPolicy visiblePolicy;
+ VisiblePolicySlop visiblePolicy;
Sci::Position searchAnchor;
bool recordingMacro;
- int foldAutomatic;
+ Scintilla::AutomaticFold foldAutomatic;
// Wrapping support
WrapPending wrapPending;
@@ -317,7 +330,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void InvalidateRange(Sci::Position start, Sci::Position end);
bool UserVirtualSpace() const noexcept {
- return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
+ return (FlagSet(virtualSpaceOptions, Scintilla::VirtualSpace::UserAccessible));
}
Sci::Position CurrentPosition() const;
bool SelectionEmpty() const noexcept;
@@ -389,8 +402,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
void PaintSelMargin(Surface *surfaceWindow, const PRectangle &rc);
void RefreshPixMaps(Surface *surfaceWindow);
void Paint(Surface *surfaceWindow, PRectangle rcArea);
- Sci::Position FormatRange(bool draw, const Sci_RangeToFormat *pfr);
- long TextWidth(uptr_t style, const char *text);
+ Sci::Position FormatRange(bool draw, const Scintilla::RangeToFormat *pfr);
+ long TextWidth(Scintilla::uptr_t style, const char *text);
virtual void SetVerticalScrollPos() = 0;
virtual void SetHorizontalScrollPos() = 0;
@@ -403,7 +416,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
Sci::Position RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace);
SelectionPosition RealizeVirtualSpace(const SelectionPosition &position);
void AddChar(char ch);
- virtual void InsertCharacter(std::string_view sv, CharacterSource charSource);
+ virtual void InsertCharacter(std::string_view sv, Scintilla::CharacterSource charSource);
void ClearBeforeTentativeStart();
void InsertPaste(const char *text, Sci::Position len);
enum class PasteShape { stream=0, rectangular = 1, line = 2 };
@@ -424,25 +437,25 @@ protected: // ScintillaBase subclass needs access to much of Editor
void DelCharBack(bool allowLineStartDeletion);
virtual void ClaimSelection() = 0;
- static int ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false, bool super=false) noexcept;
+ static Scintilla::KeyMod ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false, bool super=false) noexcept;
virtual void NotifyChange() = 0;
virtual void NotifyFocus(bool focus);
virtual void SetCtrlID(int identifier);
virtual int GetCtrlID() { return ctrlID; }
- virtual void NotifyParent(SCNotification scn) = 0;
+ virtual void NotifyParent(Scintilla::NotificationData scn) = 0;
virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded);
- void NotifyChar(int ch, CharacterSource charSource);
+ void NotifyChar(int ch, Scintilla::CharacterSource charSource);
void NotifySavePoint(bool isSavePoint);
void NotifyModifyAttempt();
- virtual void NotifyDoubleClick(Point pt, int modifiers);
- void NotifyHotSpotClicked(Sci::Position position, int modifiers);
- void NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers);
- void NotifyHotSpotReleaseClick(Sci::Position position, int modifiers);
+ virtual void NotifyDoubleClick(Point pt, Scintilla::KeyMod modifiers);
+ void NotifyHotSpotClicked(Sci::Position position, Scintilla::KeyMod modifiers);
+ void NotifyHotSpotDoubleClicked(Sci::Position position, Scintilla::KeyMod modifiers);
+ void NotifyHotSpotReleaseClick(Sci::Position position, Scintilla::KeyMod modifiers);
bool NotifyUpdateUI();
void NotifyPainted();
- void NotifyIndicatorClick(bool click, Sci::Position position, int modifiers);
- bool NotifyMarginClick(Point pt, int modifiers);
- bool NotifyMarginRightClick(Point pt, int modifiers);
+ void NotifyIndicatorClick(bool click, Sci::Position position, Scintilla::KeyMod modifiers);
+ bool NotifyMarginClick(Point pt, Scintilla::KeyMod modifiers);
+ bool NotifyMarginRightClick(Point pt, Scintilla::KeyMod modifiers);
void NotifyNeedShown(Sci::Position pos, Sci::Position len);
void NotifyDwelling(Point pt, bool state);
void NotifyZoom();
@@ -454,10 +467,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
void NotifyDeleted(Document *document, void *userData) noexcept override;
void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endStyleNeeded) override;
void NotifyLexerChanged(Document *doc, void *userData) override;
- void NotifyErrorOccurred(Document *doc, void *userData, int status) override;
- void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+ void NotifyErrorOccurred(Document *doc, void *userData, Scintilla::Status status) override;
+ void NotifyMacroRecord(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
- void ContainerNeedsUpdate(int flags) noexcept;
+ void ContainerNeedsUpdate(Scintilla::Update flags) noexcept;
void PageMove(int direction, Selection::SelTypes selt=Selection::SelTypes::none, bool stuttered = false);
enum class CaseMapping { same, upper, lower };
virtual std::string CaseMapString(const std::string &s, CaseMapping caseMapping);
@@ -475,18 +488,18 @@ protected: // ScintillaBase subclass needs access to much of Editor
Sci::Position VCHomeDisplayPosition(Sci::Position position);
Sci::Position VCHomeWrapPosition(Sci::Position position);
Sci::Position LineEndWrapPosition(Sci::Position position);
- int HorizontalMove(unsigned int iMessage);
- int DelWordOrLine(unsigned int iMessage);
- virtual int KeyCommand(unsigned int iMessage);
- virtual int KeyDefault(int /* key */, int /*modifiers*/);
- int KeyDownWithModifiers(int key, int modifiers, bool *consumed);
+ int HorizontalMove(Scintilla::Message iMessage);
+ int DelWordOrLine(Scintilla::Message iMessage);
+ virtual int KeyCommand(Scintilla::Message iMessage);
+ virtual int KeyDefault(Scintilla::Keys /* key */, Scintilla::KeyMod /*modifiers*/);
+ int KeyDownWithModifiers(Scintilla::Keys key, Scintilla::KeyMod modifiers, bool *consumed);
void Indent(bool forwards);
virtual std::unique_ptr<CaseFolder> CaseFolderForEncoding();
- Sci::Position FindText(uptr_t wParam, sptr_t lParam);
+ Sci::Position FindText(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
void SearchAnchor();
- Sci::Position SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+ 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);
@@ -511,10 +524,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
void WordSelection(Sci::Position pos);
void DwellEnd(bool mouseMoved);
void MouseLeave();
- virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
- virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
- void ButtonMoveWithModifiers(Point pt, unsigned int curTime, int modifiers);
- void ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers);
+ virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers);
+ virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers);
+ void ButtonMoveWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers);
+ void ButtonUpWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers);
bool Idle();
enum class TickReason { caret, scroll, widen, dwell, platform };
@@ -534,13 +547,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
void StartIdleStyling(bool truncatedLastStyling);
void StyleAreaBounded(PRectangle rcArea, bool scrolling);
constexpr bool SynchronousStylingToVisible() const noexcept {
- return (idleStyling == SC_IDLESTYLING_NONE) || (idleStyling == SC_IDLESTYLING_AFTERVISIBLE);
+ return (idleStyling == Scintilla::IdleStyling::None) || (idleStyling == Scintilla::IdleStyling::AfterVisible);
}
- void IdleStyling();
+ void IdleStyle();
virtual void IdleWork();
virtual void QueueIdleWork(WorkItems items, Sci::Position upTo=0);
- virtual int SupportsFeature(int feature);
+ virtual int SupportsFeature(Scintilla::Supports feature);
virtual bool PaintContains(PRectangle rc);
bool PaintContainsMargin();
void CheckForChangeOutsidePaint(Range r);
@@ -549,18 +562,18 @@ protected: // ScintillaBase subclass needs access to much of Editor
void SetAnnotationHeights(Sci::Line start, Sci::Line end);
virtual void SetDocPointer(Document *document);
- void SetAnnotationVisible(int visible);
- void SetEOLAnnotationVisible(int visible);
+ void SetAnnotationVisible(Scintilla::AnnotationVisible visible);
+ void SetEOLAnnotationVisible(Scintilla::EOLAnnotationVisible visible);
Sci::Line ExpandLine(Sci::Line line);
void SetFoldExpanded(Sci::Line lineDoc, bool expanded);
- void FoldLine(Sci::Line line, int action);
- void FoldExpand(Sci::Line line, int action, int level);
+ void FoldLine(Sci::Line line, Scintilla::FoldAction action);
+ void FoldExpand(Sci::Line line, Scintilla::FoldAction action, Scintilla::FoldLevel level);
Sci::Line ContractedFoldNext(Sci::Line lineStart) const;
void EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy);
- void FoldChanged(Sci::Line line, int levelNow, int levelPrev);
+ void FoldChanged(Sci::Line line, Scintilla::FoldLevel levelNow, Scintilla::FoldLevel levelPrev);
void NeedShown(Sci::Position pos, Sci::Position len);
- void FoldAll(int action);
+ void FoldAll(Scintilla::FoldAction action);
Sci::Position GetTag(char *tagValue, int tagNumber);
Sci::Position ReplaceTarget(bool replacePatterns, const char *text, Sci::Position length=-1);
@@ -580,39 +593,39 @@ protected: // ScintillaBase subclass needs access to much of Editor
Sci::Line WrapCount(Sci::Line line);
void AddStyledText(const char *buffer, Sci::Position appendLength);
- virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
- bool ValidMargin(uptr_t wParam) const noexcept;
- void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
- sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
- void SetSelectionNMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+ virtual Scintilla::sptr_t DefWndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) = 0;
+ bool ValidMargin(Scintilla::uptr_t wParam) const noexcept;
+ void StyleSetMessage(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
+ Scintilla::sptr_t StyleGetMessage(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
+ void SetSelectionNMessage(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
- static const char *StringFromEOLMode(int eolMode) noexcept;
+ static const char *StringFromEOLMode(Scintilla::EndOfLine eolMode) noexcept;
// Coercion functions for transforming WndProc parameters into pointers
- static void *PtrFromSPtr(sptr_t lParam) noexcept {
+ static void *PtrFromSPtr(Scintilla::sptr_t lParam) noexcept {
return reinterpret_cast<void *>(lParam);
}
- static const char *ConstCharPtrFromSPtr(sptr_t lParam) noexcept {
+ static const char *ConstCharPtrFromSPtr(Scintilla::sptr_t lParam) noexcept {
return static_cast<const char *>(PtrFromSPtr(lParam));
}
- static const unsigned char *ConstUCharPtrFromSPtr(sptr_t lParam) noexcept {
+ static const unsigned char *ConstUCharPtrFromSPtr(Scintilla::sptr_t lParam) noexcept {
return static_cast<const unsigned char *>(PtrFromSPtr(lParam));
}
- static char *CharPtrFromSPtr(sptr_t lParam) noexcept {
+ static char *CharPtrFromSPtr(Scintilla::sptr_t lParam) noexcept {
return static_cast<char *>(PtrFromSPtr(lParam));
}
- static unsigned char *UCharPtrFromSPtr(sptr_t lParam) noexcept {
+ static unsigned char *UCharPtrFromSPtr(Scintilla::sptr_t lParam) noexcept {
return static_cast<unsigned char *>(PtrFromSPtr(lParam));
}
- static void *PtrFromUPtr(uptr_t wParam) noexcept {
+ static void *PtrFromUPtr(Scintilla::uptr_t wParam) noexcept {
return reinterpret_cast<void *>(wParam);
}
- static const char *ConstCharPtrFromUPtr(uptr_t wParam) noexcept {
+ static const char *ConstCharPtrFromUPtr(Scintilla::uptr_t wParam) noexcept {
return static_cast<const char *>(PtrFromUPtr(wParam));
}
- static sptr_t StringResult(sptr_t lParam, const char *val) noexcept;
- static sptr_t BytesResult(sptr_t lParam, const unsigned char *val, size_t len) noexcept;
+ static Scintilla::sptr_t StringResult(Scintilla::sptr_t lParam, const char *val) noexcept;
+ static Scintilla::sptr_t BytesResult(Scintilla::sptr_t lParam, const unsigned char *val, size_t len) noexcept;
// Set a variable controlling appearance to a value and invalidates the display
// if a change was made. Avoids extra text and the possibility of mistyping.
@@ -633,11 +646,11 @@ public:
// Public so the COM thunks can access it.
bool IsUnicodeMode() const noexcept;
// Public so scintilla_send_message can use it.
- virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+ virtual Scintilla::sptr_t WndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
// Public so scintilla_set_id can use it.
int ctrlID;
// Public so COM methods for drag and drop can set it.
- int errorStatus;
+ Scintilla::Status errorStatus;
friend class AutoSurface;
};
@@ -648,16 +661,16 @@ class AutoSurface {
private:
std::unique_ptr<Surface> surf;
public:
- AutoSurface(const Editor *ed, int technology = -1) {
+ AutoSurface(const Editor *ed) {
if (ed->wMain.GetID()) {
- surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
+ surf = Surface::Allocate(ed->technology);
surf->Init(ed->wMain.GetID());
surf->SetMode(SurfaceMode(ed->CodePage(), ed->BidirectionalR2L()));
}
}
- AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) {
+ AutoSurface(SurfaceID sid, Editor *ed, std::optional<Scintilla::Technology> technology = {}) {
if (ed->wMain.GetID()) {
- surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
+ surf = Surface::Allocate(technology ? *technology : ed->technology);
surf->Init(sid, ed->wMain.GetID());
surf->SetMode(SurfaceMode(ed->CodePage(), ed->BidirectionalR2L()));
}
diff --git a/src/ElapsedPeriod.h b/src/ElapsedPeriod.h
index f744c2e63..36f03e162 100644
--- a/src/ElapsedPeriod.h
+++ b/src/ElapsedPeriod.h
@@ -8,7 +8,7 @@
#ifndef ELAPSEDPERIOD_H
#define ELAPSEDPERIOD_H
-namespace Scintilla {
+namespace Scintilla::Internal {
// Simplified access to high precision timing.
class ElapsedPeriod {
diff --git a/src/FontQuality.h b/src/FontQuality.h
index 85dca1e16..b587fc6d4 100644
--- a/src/FontQuality.h
+++ b/src/FontQuality.h
@@ -12,15 +12,15 @@
namespace Scintilla {
// These definitions match Scintilla.h
-#define SC_EFF_QUALITY_MASK 0xF
-#define SC_EFF_QUALITY_DEFAULT 0
-#define SC_EFF_QUALITY_NON_ANTIALIASED 1
-#define SC_EFF_QUALITY_ANTIALIASED 2
-#define SC_EFF_QUALITY_LCD_OPTIMIZED 3
+//#define SC_EFF_QUALITY_MASK 0xF
+//#define SC_EFF_QUALITY_DEFAULT 0
+//#define SC_EFF_QUALITY_NON_ANTIALIASED 1
+//#define SC_EFF_QUALITY_ANTIALIASED 2
+//#define SC_EFF_QUALITY_LCD_OPTIMIZED 3
// These definitions must match SC_TECHNOLOGY_* in Scintilla.h
-#define SCWIN_TECH_GDI 0
-#define SCWIN_TECH_DIRECTWRITE 1
+//#define SCWIN_TECH_GDI 0
+//#define SCWIN_TECH_DIRECTWRITE 1
}
diff --git a/src/Geometry.cxx b/src/Geometry.cxx
index 68ce1f628..9eea41345 100644
--- a/src/Geometry.cxx
+++ b/src/Geometry.cxx
@@ -11,7 +11,7 @@
#include "Geometry.h"
-namespace Scintilla {
+namespace Scintilla::Internal {
PRectangle Clamp(PRectangle rc, Edge edge, XYPOSITION position) noexcept {
switch (edge) {
diff --git a/src/Geometry.h b/src/Geometry.h
index 40289dc89..e471bdfc0 100644
--- a/src/Geometry.h
+++ b/src/Geometry.h
@@ -8,17 +8,11 @@
#ifndef GEOMETRY_H
#define GEOMETRY_H
-namespace Scintilla {
+namespace Scintilla::Internal {
typedef double XYPOSITION;
typedef double XYACCUMULATOR;
-// Test if an enum class value has the bit flag(s) of test set.
-template <typename T>
-constexpr bool FlagSet(T value, T test) {
- return (static_cast<int>(value) & static_cast<int>(test)) == static_cast<int>(test);
-}
-
/**
* A geometric point class.
* Point is similar to the Win32 POINT and GTK+ GdkPoint types.
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index c93855af5..0dd9ba7c2 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -15,20 +15,22 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
#include "Indicator.h"
#include "XPM.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, State state, int value) const {
StyleAndColour sacDraw = sacNormal;
- if (Flags() & SC_INDICFLAG_VALUEFORE) {
- sacDraw.fore = ColourRGBA::FromRGB(value & SC_INDICVALUEMASK);
+ if (FlagSet(Flags(), IndicFlag::ValueFore)) {
+ sacDraw.fore = ColourRGBA::FromRGB(value & static_cast<int>(IndicValue::Mask));
}
if (state == State::hover) {
sacDraw = sacHover;
@@ -50,7 +52,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
rcClip.bottom = rcFullHeightAligned.bottom;
switch (sacDraw.style) {
- case INDIC_SQUIGGLE: {
+ case IndicatorStyle::Squiggle: {
surface->SetClip(rcClip);
XYPOSITION x = rcAligned.left + halfWidth;
const XYPOSITION top = rcAligned.top + halfWidth;
@@ -69,7 +71,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_SQUIGGLEPIXMAP: {
+ case IndicatorStyle::SquigglePixmap: {
const PRectangle rcSquiggle = PixelAlign(rc, 1);
const int width = std::min(4000, static_cast<int>(rcSquiggle.Width()));
@@ -93,7 +95,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_SQUIGGLELOW: {
+ case IndicatorStyle::SquiggleLow: {
std::vector<Point> pts;
const XYPOSITION top = rcAligned.top + halfWidth;
int y = 0;
@@ -112,7 +114,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_TT: {
+ case IndicatorStyle::TT: {
surface->SetClip(rcClip);
const XYPOSITION yLine = ymid;
XYPOSITION x = rcAligned.left + 5.0f;
@@ -129,7 +131,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_DIAGONAL: {
+ case IndicatorStyle::Diagonal: {
surface->SetClip(rcClip);
XYPOSITION x = rcAligned.left + halfWidth;
const XYPOSITION top = rcAligned.top + halfWidth;
@@ -144,7 +146,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_STRIKE: {
+ case IndicatorStyle::Strike: {
const XYPOSITION yStrike = std::round(rcLine.Centre().y);
const PRectangle rcStrike(
rcAligned.left, yStrike, rcAligned.right, yStrike + strokeWidth);
@@ -152,12 +154,12 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_HIDDEN:
- case INDIC_TEXTFORE:
+ case IndicatorStyle::Hidden:
+ case IndicatorStyle::TextFore:
// Draw nothing
break;
- case INDIC_BOX: {
+ case IndicatorStyle::Box: {
PRectangle rcBox = rcFullHeightAligned;
rcBox.top = rcBox.top + 1.0f;
rcBox.bottom = ymid + 1.0f;
@@ -165,19 +167,19 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_ROUNDBOX:
- case INDIC_STRAIGHTBOX:
- case INDIC_FULLBOX: {
+ case IndicatorStyle::RoundBox:
+ case IndicatorStyle::StraightBox:
+ case IndicatorStyle::FullBox: {
PRectangle rcBox = rcFullHeightAligned;
- if (sacDraw.style != INDIC_FULLBOX)
+ if (sacDraw.style != IndicatorStyle::FullBox)
rcBox.top = rcBox.top + 1;
- surface->AlphaRectangle(rcBox, (sacDraw.style == INDIC_ROUNDBOX) ? 1.0f : 0.0f,
+ surface->AlphaRectangle(rcBox, (sacDraw.style == IndicatorStyle::RoundBox) ? 1.0f : 0.0f,
FillStroke(ColourRGBA(sacDraw.fore, fillAlpha), ColourRGBA(sacDraw.fore, outlineAlpha), strokeWidth));
}
break;
- case INDIC_GRADIENT:
- case INDIC_GRADIENTCENTRE: {
+ case IndicatorStyle::Gradient:
+ case IndicatorStyle::GradientCentre: {
PRectangle rcBox = rcFullHeightAligned;
rcBox.top = rcBox.top + 1;
const Surface::GradientOptions options = Surface::GradientOptions::topToBottom;
@@ -185,21 +187,23 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
const ColourRGBA end(sacDraw.fore, 0);
std::vector<ColourStop> stops;
switch (sacDraw.style) {
- case INDIC_GRADIENT:
+ case IndicatorStyle::Gradient:
stops.push_back(ColourStop(0.0, start));
stops.push_back(ColourStop(1.0, end));
break;
- case INDIC_GRADIENTCENTRE:
+ case IndicatorStyle::GradientCentre:
stops.push_back(ColourStop(0.0, end));
stops.push_back(ColourStop(0.5, start));
stops.push_back(ColourStop(1.0, end));
break;
+ default:
+ break;
}
surface->GradientRectangle(rcBox, stops, options);
}
break;
- case INDIC_DOTBOX: {
+ case IndicatorStyle::DotBox: {
PRectangle rcBox = rcFullHeightAligned;
rcBox.top = rcBox.top + 1;
// Cap width at 4000 to avoid large allocations when mistakes made
@@ -222,7 +226,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_DASH: {
+ case IndicatorStyle::Dash: {
XYPOSITION x = std::floor(rc.left);
const XYPOSITION widthDash = 3 + std::round(strokeWidth);
while (x < rc.right) {
@@ -234,7 +238,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_DOTS: {
+ case IndicatorStyle::Dots: {
const XYPOSITION widthDot = std::round(strokeWidth);
XYPOSITION x = std::floor(rc.left);
while (x < rc.right) {
@@ -246,23 +250,23 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
break;
- case INDIC_COMPOSITIONTHICK: {
+ case IndicatorStyle::CompositionThick: {
const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom);
surface->FillRectangle(rcComposition, sacDraw.fore);
}
break;
- case INDIC_COMPOSITIONTHIN: {
+ case IndicatorStyle::CompositionThin: {
const PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom-1);
surface->FillRectangle(rcComposition, sacDraw.fore);
}
break;
- case INDIC_POINT:
- case INDIC_POINTCHARACTER:
+ case IndicatorStyle::Point:
+ case IndicatorStyle::PointCharacter:
if (rcCharacter.Width() >= 0.1) {
const XYPOSITION pixelHeight = std::floor(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase
- const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2);
+ const XYPOSITION x = (sacDraw.style == IndicatorStyle::Point) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2);
// 0.5f is to hit midpoint of pixels:
const XYPOSITION ix = std::round(x) + 0.5f;
const XYPOSITION iy = std::floor(rc.top + 1.0f) + 0.5f;
@@ -276,12 +280,12 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
break;
default:
- // Either INDIC_PLAIN or unknown
+ // Either IndicatorStyle::Plain or unknown
surface->FillRectangle(PRectangle(rcAligned.left, ymid,
rcAligned.right, ymid + std::round(strokeWidth)), sacDraw.fore);
}
}
-void Indicator::SetFlags(int attributes_) noexcept {
+void Indicator::SetFlags(IndicFlag attributes_) noexcept {
attributes = attributes_;
}
diff --git a/src/Indicator.h b/src/Indicator.h
index 11851476e..fc17a82c2 100644
--- a/src/Indicator.h
+++ b/src/Indicator.h
@@ -8,14 +8,14 @@
#ifndef INDICATOR_H
#define INDICATOR_H
-namespace Scintilla {
+namespace Scintilla::Internal {
struct StyleAndColour {
- int style;
+ Scintilla::IndicatorStyle style;
ColourRGBA fore;
- StyleAndColour() noexcept : style(INDIC_PLAIN), fore(0, 0, 0) {
+ StyleAndColour() noexcept : style(Scintilla::IndicatorStyle::Plain), fore(0, 0, 0) {
}
- StyleAndColour(int style_, ColourRGBA fore_ = ColourRGBA(0, 0, 0)) noexcept : style(style_), fore(fore_) {
+ StyleAndColour(Scintilla::IndicatorStyle style_, ColourRGBA fore_ = ColourRGBA(0, 0, 0)) noexcept : style(style_), fore(fore_) {
}
bool operator==(const StyleAndColour &other) const noexcept {
return (style == other.style) && (fore == other.fore);
@@ -32,24 +32,24 @@ public:
bool under;
int fillAlpha;
int outlineAlpha;
- int attributes;
+ Scintilla::IndicFlag attributes;
XYPOSITION strokeWidth = 1.0f;
- Indicator() noexcept : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) {
+ Indicator() noexcept : under(false), fillAlpha(30), outlineAlpha(50), attributes(Scintilla::IndicFlag::None) {
}
- Indicator(int style_, ColourRGBA fore_= ColourRGBA(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) noexcept :
- sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) {
+ Indicator(Scintilla::IndicatorStyle style_, ColourRGBA fore_= ColourRGBA(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) noexcept :
+ sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(Scintilla::IndicFlag::None) {
}
void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, State drawState, int value) const;
bool IsDynamic() const noexcept {
return !(sacNormal == sacHover);
}
bool OverridesTextFore() const noexcept {
- return sacNormal.style == INDIC_TEXTFORE || sacHover.style == INDIC_TEXTFORE;
+ return sacNormal.style == Scintilla::IndicatorStyle::TextFore || sacHover.style == Scintilla::IndicatorStyle::TextFore;
}
- int Flags() const noexcept {
+ Scintilla::IndicFlag Flags() const noexcept {
return attributes;
}
- void SetFlags(int attributes_) noexcept;
+ void SetFlags(Scintilla::IndicFlag attributes_) noexcept;
};
}
diff --git a/src/KeyMap.cxx b/src/KeyMap.cxx
index dbd7d923e..ae189db55 100644
--- a/src/KeyMap.cxx
+++ b/src/KeyMap.cxx
@@ -14,16 +14,18 @@
#include <optional>
#include <memory>
-#include "Debugging.h"
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
-#include "Scintilla.h"
+#include "Debugging.h"
#include "KeyMap.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
KeyMap::KeyMap() {
- for (int i = 0; MapDefault[i].key; i++) {
+ for (int i = 0; static_cast<int>(MapDefault[i].key); i++) {
AssignCmdKey(MapDefault[i].key,
MapDefault[i].modifiers,
MapDefault[i].msg);
@@ -38,16 +40,16 @@ void KeyMap::Clear() noexcept {
kmap.clear();
}
-void KeyMap::AssignCmdKey(int key, int modifiers, unsigned int msg) {
+void KeyMap::AssignCmdKey(Keys key, KeyMod modifiers, Message msg) {
kmap[KeyModifiers(key, modifiers)] = msg;
}
-unsigned int KeyMap::Find(int key, int modifiers) const {
- std::map<KeyModifiers, unsigned int>::const_iterator it = kmap.find(KeyModifiers(key, modifiers));
- return (it == kmap.end()) ? 0 : it->second;
+Message KeyMap::Find(Keys key, KeyMod modifiers) const {
+ std::map<KeyModifiers, Message>::const_iterator it = kmap.find(KeyModifiers(key, modifiers));
+ return (it == kmap.end()) ? static_cast<Message>(0) : it->second;
}
-const std::map<KeyModifiers, unsigned int> &KeyMap::GetKeyMap() const noexcept {
+const std::map<KeyModifiers, Message> &KeyMap::GetKeyMap() const noexcept {
return kmap;
}
@@ -67,100 +69,108 @@ const std::map<KeyModifiers, unsigned int> &KeyMap::GetKeyMap() const noexcept {
#define SCI_SCTRL_META (SCI_CTRL | SCI_SHIFT)
#endif
+namespace {
+
+constexpr Keys Key(char ch) {
+ return static_cast<Keys>(ch);
+}
+
+}
+
const KeyToCommand KeyMap::MapDefault[] = {
#if OS_X_KEYS
- {SCK_DOWN, SCI_CTRL, SCI_DOCUMENTEND},
- {SCK_DOWN, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND},
- {SCK_UP, SCI_CTRL, SCI_DOCUMENTSTART},
- {SCK_UP, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND},
- {SCK_LEFT, SCI_CTRL, SCI_VCHOME},
- {SCK_LEFT, SCI_CSHIFT, SCI_VCHOMEEXTEND},
- {SCK_RIGHT, SCI_CTRL, SCI_LINEEND},
- {SCK_RIGHT, SCI_CSHIFT, SCI_LINEENDEXTEND},
+ {Keys::Down, SCI_CTRL, Message::DocumentEnd},
+ {Keys::Down, SCI_CSHIFT, Message::DocumentEndExtend},
+ {Keys::Up, SCI_CTRL, Message::DocumentStart},
+ {Keys::Up, SCI_CSHIFT, Message::DocumentStartExtend},
+ {Keys::Left, SCI_CTRL, Message::VCHome},
+ {Keys::Left, SCI_CSHIFT, Message::VCHomeExtend},
+ {Keys::Right, SCI_CTRL, Message::LineEnd},
+ {Keys::Right, SCI_CSHIFT, Message::LineEndExtend},
#endif
- {SCK_DOWN, SCI_NORM, SCI_LINEDOWN},
- {SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND},
- {SCK_DOWN, SCI_CTRL_META, SCI_LINESCROLLDOWN},
- {SCK_DOWN, SCI_ASHIFT, SCI_LINEDOWNRECTEXTEND},
- {SCK_UP, SCI_NORM, SCI_LINEUP},
- {SCK_UP, SCI_SHIFT, SCI_LINEUPEXTEND},
- {SCK_UP, SCI_CTRL_META, SCI_LINESCROLLUP},
- {SCK_UP, SCI_ASHIFT, SCI_LINEUPRECTEXTEND},
- {'[', SCI_CTRL, SCI_PARAUP},
- {'[', SCI_CSHIFT, SCI_PARAUPEXTEND},
- {']', SCI_CTRL, SCI_PARADOWN},
- {']', SCI_CSHIFT, SCI_PARADOWNEXTEND},
- {SCK_LEFT, SCI_NORM, SCI_CHARLEFT},
- {SCK_LEFT, SCI_SHIFT, SCI_CHARLEFTEXTEND},
- {SCK_LEFT, SCI_CTRL_META, SCI_WORDLEFT},
- {SCK_LEFT, SCI_SCTRL_META, SCI_WORDLEFTEXTEND},
- {SCK_LEFT, SCI_ASHIFT, SCI_CHARLEFTRECTEXTEND},
- {SCK_RIGHT, SCI_NORM, SCI_CHARRIGHT},
- {SCK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND},
- {SCK_RIGHT, SCI_CTRL_META, SCI_WORDRIGHT},
- {SCK_RIGHT, SCI_SCTRL_META, SCI_WORDRIGHTEXTEND},
- {SCK_RIGHT, SCI_ASHIFT, SCI_CHARRIGHTRECTEXTEND},
- {'/', SCI_CTRL, SCI_WORDPARTLEFT},
- {'/', SCI_CSHIFT, SCI_WORDPARTLEFTEXTEND},
- {'\\', SCI_CTRL, SCI_WORDPARTRIGHT},
- {'\\', SCI_CSHIFT, SCI_WORDPARTRIGHTEXTEND},
- {SCK_HOME, SCI_NORM, SCI_VCHOME},
- {SCK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND},
- {SCK_HOME, SCI_CTRL, SCI_DOCUMENTSTART},
- {SCK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND},
- {SCK_HOME, SCI_ALT, SCI_HOMEDISPLAY},
- {SCK_HOME, SCI_ASHIFT, SCI_VCHOMERECTEXTEND},
- {SCK_END, SCI_NORM, SCI_LINEEND},
- {SCK_END, SCI_SHIFT, SCI_LINEENDEXTEND},
- {SCK_END, SCI_CTRL, SCI_DOCUMENTEND},
- {SCK_END, SCI_CSHIFT, SCI_DOCUMENTENDEXTEND},
- {SCK_END, SCI_ALT, SCI_LINEENDDISPLAY},
- {SCK_END, SCI_ASHIFT, SCI_LINEENDRECTEXTEND},
- {SCK_PRIOR, SCI_NORM, SCI_PAGEUP},
- {SCK_PRIOR, SCI_SHIFT, SCI_PAGEUPEXTEND},
- {SCK_PRIOR, SCI_ASHIFT, SCI_PAGEUPRECTEXTEND},
- {SCK_NEXT, SCI_NORM, SCI_PAGEDOWN},
- {SCK_NEXT, SCI_SHIFT, SCI_PAGEDOWNEXTEND},
- {SCK_NEXT, SCI_ASHIFT, SCI_PAGEDOWNRECTEXTEND},
- {SCK_DELETE, SCI_NORM, SCI_CLEAR},
- {SCK_DELETE, SCI_SHIFT, SCI_CUT},
- {SCK_DELETE, SCI_CTRL, SCI_DELWORDRIGHT},
- {SCK_DELETE, SCI_CSHIFT, SCI_DELLINERIGHT},
- {SCK_INSERT, SCI_NORM, SCI_EDITTOGGLEOVERTYPE},
- {SCK_INSERT, SCI_SHIFT, SCI_PASTE},
- {SCK_INSERT, SCI_CTRL, SCI_COPY},
- {SCK_ESCAPE, SCI_NORM, SCI_CANCEL},
- {SCK_BACK, SCI_NORM, SCI_DELETEBACK},
- {SCK_BACK, SCI_SHIFT, SCI_DELETEBACK},
- {SCK_BACK, SCI_CTRL, SCI_DELWORDLEFT},
- {SCK_BACK, SCI_ALT, SCI_UNDO},
- {SCK_BACK, SCI_CSHIFT, SCI_DELLINELEFT},
- {'Z', SCI_CTRL, SCI_UNDO},
+ {Keys::Down, SCI_NORM, Message::LineDown},
+ {Keys::Down, SCI_SHIFT, Message::LineDownExtend},
+ {Keys::Down, SCI_CTRL_META, Message::LineScrollDown},
+ {Keys::Down, SCI_ASHIFT, Message::LineDownRectExtend},
+ {Keys::Up, SCI_NORM, Message::LineUp},
+ {Keys::Up, SCI_SHIFT, Message::LineUpExtend},
+ {Keys::Up, SCI_CTRL_META, Message::LineScrollUp},
+ {Keys::Up, SCI_ASHIFT, Message::LineUpRectExtend},
+ {Key('['), SCI_CTRL, Message::ParaUp},
+ {Key('['), SCI_CSHIFT, Message::ParaUpExtend},
+ {Key(']'), SCI_CTRL, Message::ParaDown},
+ {Key(']'), SCI_CSHIFT, Message::ParaDownExtend},
+ {Keys::Left, SCI_NORM, Message::CharLeft},
+ {Keys::Left, SCI_SHIFT, Message::CharLeftExtend},
+ {Keys::Left, SCI_CTRL_META, Message::WordLeft},
+ {Keys::Left, SCI_SCTRL_META, Message::WordLeftExtend},
+ {Keys::Left, SCI_ASHIFT, Message::CharLeftRectExtend},
+ {Keys::Right, SCI_NORM, Message::CharRight},
+ {Keys::Right, SCI_SHIFT, Message::CharRightExtend},
+ {Keys::Right, SCI_CTRL_META, Message::WordRight},
+ {Keys::Right, SCI_SCTRL_META, Message::WordRightExtend},
+ {Keys::Right, SCI_ASHIFT, Message::CharRightRectExtend},
+ {Key('/'), SCI_CTRL, Message::WordPartLeft},
+ {Key('/'), SCI_CSHIFT, Message::WordPartLeftExtend},
+ {Key('\\'), SCI_CTRL, Message::WordPartRight},
+ {Key('\\'), SCI_CSHIFT, Message::WordPartRightExtend},
+ {Keys::Home, SCI_NORM, Message::VCHome},
+ {Keys::Home, SCI_SHIFT, Message::VCHomeExtend},
+ {Keys::Home, SCI_CTRL, Message::DocumentStart},
+ {Keys::Home, SCI_CSHIFT, Message::DocumentStartExtend},
+ {Keys::Home, SCI_ALT, Message::HomeDisplay},
+ {Keys::Home, SCI_ASHIFT, Message::VCHomeRectExtend},
+ {Keys::End, SCI_NORM, Message::LineEnd},
+ {Keys::End, SCI_SHIFT, Message::LineEndExtend},
+ {Keys::End, SCI_CTRL, Message::DocumentEnd},
+ {Keys::End, SCI_CSHIFT, Message::DocumentEndExtend},
+ {Keys::End, SCI_ALT, Message::LineEndDisplay},
+ {Keys::End, SCI_ASHIFT, Message::LineEndRectExtend},
+ {Keys::Prior, SCI_NORM, Message::PageUp},
+ {Keys::Prior, SCI_SHIFT, Message::PageUpExtend},
+ {Keys::Prior, SCI_ASHIFT, Message::PageUpRectExtend},
+ {Keys::Next, SCI_NORM, Message::PageDown},
+ {Keys::Next, SCI_SHIFT, Message::PageDownExtend},
+ {Keys::Next, SCI_ASHIFT, Message::PageDownRectExtend},
+ {Keys::Delete, SCI_NORM, Message::Clear},
+ {Keys::Delete, SCI_SHIFT, Message::Cut},
+ {Keys::Delete, SCI_CTRL, Message::DelWordRight},
+ {Keys::Delete, SCI_CSHIFT, Message::DelLineRight},
+ {Keys::Insert, SCI_NORM, Message::EditToggleOvertype},
+ {Keys::Insert, SCI_SHIFT, Message::Paste},
+ {Keys::Insert, SCI_CTRL, Message::Copy},
+ {Keys::Escape, SCI_NORM, Message::Cancel},
+ {Keys::Back, SCI_NORM, Message::DeleteBack},
+ {Keys::Back, SCI_SHIFT, Message::DeleteBack},
+ {Keys::Back, SCI_CTRL, Message::DelWordLeft},
+ {Keys::Back, SCI_ALT, Message::Undo},
+ {Keys::Back, SCI_CSHIFT, Message::DelLineLeft},
+ {Key('Z'), SCI_CTRL, Message::Undo},
#if OS_X_KEYS
- {'Z', SCI_CSHIFT, SCI_REDO},
+ {Key('Z'), SCI_CSHIFT, Message::Redo},
#else
- {'Y', SCI_CTRL, SCI_REDO},
+ {Key('Y'), SCI_CTRL, Message::Redo},
#endif
- {'X', SCI_CTRL, SCI_CUT},
- {'C', SCI_CTRL, SCI_COPY},
- {'V', SCI_CTRL, SCI_PASTE},
- {'A', SCI_CTRL, SCI_SELECTALL},
- {SCK_TAB, SCI_NORM, SCI_TAB},
- {SCK_TAB, SCI_SHIFT, SCI_BACKTAB},
- {SCK_RETURN, SCI_NORM, SCI_NEWLINE},
- {SCK_RETURN, SCI_SHIFT, SCI_NEWLINE},
- {SCK_ADD, SCI_CTRL, SCI_ZOOMIN},
- {SCK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT},
- {SCK_DIVIDE, SCI_CTRL, SCI_SETZOOM},
- {'L', SCI_CTRL, SCI_LINECUT},
- {'L', SCI_CSHIFT, SCI_LINEDELETE},
- {'T', SCI_CSHIFT, SCI_LINECOPY},
- {'T', SCI_CTRL, SCI_LINETRANSPOSE},
- {'D', SCI_CTRL, SCI_SELECTIONDUPLICATE},
- {'U', SCI_CTRL, SCI_LOWERCASE},
- {'U', SCI_CSHIFT, SCI_UPPERCASE},
- {0,0,0},
+ {Key('X'), SCI_CTRL, Message::Cut},
+ {Key('C'), SCI_CTRL, Message::Copy},
+ {Key('V'), SCI_CTRL, Message::Paste},
+ {Key('A'), SCI_CTRL, Message::SelectAll},
+ {Keys::Tab, SCI_NORM, Message::Tab},
+ {Keys::Tab, SCI_SHIFT, Message::BackTab},
+ {Keys::Return, SCI_NORM, Message::NewLine},
+ {Keys::Return, SCI_SHIFT, Message::NewLine},
+ {Keys::Add, SCI_CTRL, Message::ZoomIn},
+ {Keys::Subtract, SCI_CTRL, Message::ZoomOut},
+ {Keys::Divide, SCI_CTRL, Message::SetZoom},
+ {Key('L'), SCI_CTRL, Message::LineCut},
+ {Key('L'), SCI_CSHIFT, Message::LineDelete},
+ {Key('T'), SCI_CSHIFT, Message::LineCopy},
+ {Key('T'), SCI_CTRL, Message::LineTranspose},
+ {Key('D'), SCI_CTRL, Message::SelectionDuplicate},
+ {Key('U'), SCI_CTRL, Message::LowerCase},
+ {Key('U'), SCI_CSHIFT, Message::UpperCase},
+ {Key(0),SCI_NORM,static_cast<Message>(0)},
};
diff --git a/src/KeyMap.h b/src/KeyMap.h
index 245b6daaa..6662118b2 100644
--- a/src/KeyMap.h
+++ b/src/KeyMap.h
@@ -8,24 +8,24 @@
#ifndef KEYMAP_H
#define KEYMAP_H
-namespace Scintilla {
+namespace Scintilla::Internal {
-#define SCI_NORM 0
-#define SCI_SHIFT SCMOD_SHIFT
-#define SCI_CTRL SCMOD_CTRL
-#define SCI_ALT SCMOD_ALT
-#define SCI_META SCMOD_META
-#define SCI_SUPER SCMOD_SUPER
-#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
-#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
+#define SCI_NORM KeyMod::Norm
+#define SCI_SHIFT KeyMod::Shift
+#define SCI_CTRL KeyMod::Ctrl
+#define SCI_ALT KeyMod::Alt
+#define SCI_META KeyMod::Meta
+#define SCI_SUPER KeyMod::Super
+#define SCI_CSHIFT (KeyMod::Ctrl | KeyMod::Shift)
+#define SCI_ASHIFT (KeyMod::Alt | KeyMod::Shift)
/**
*/
class KeyModifiers {
public:
- int key;
- int modifiers;
- KeyModifiers(int key_, int modifiers_) noexcept : key(key_), modifiers(modifiers_) {
+ Scintilla::Keys key;
+ Scintilla::KeyMod modifiers;
+ KeyModifiers(Scintilla::Keys key_, Scintilla::KeyMod modifiers_) noexcept : key(key_), modifiers(modifiers_) {
}
bool operator<(const KeyModifiers &other) const noexcept {
if (key == other.key)
@@ -39,24 +39,24 @@ public:
*/
class KeyToCommand {
public:
- int key;
- int modifiers;
- unsigned int msg;
+ Scintilla::Keys key;
+ Scintilla::KeyMod modifiers;
+ Scintilla::Message msg;
};
/**
*/
class KeyMap {
- std::map<KeyModifiers, unsigned int> kmap;
+ std::map<KeyModifiers, Scintilla::Message> kmap;
static const KeyToCommand MapDefault[];
public:
KeyMap();
~KeyMap();
void Clear() noexcept;
- void AssignCmdKey(int key, int modifiers, unsigned int msg);
- unsigned int Find(int key, int modifiers) const; // 0 returned on failure
- const std::map<KeyModifiers, unsigned int> &GetKeyMap() const noexcept;
+ void AssignCmdKey(Scintilla::Keys key, Scintilla::KeyMod modifiers, Scintilla::Message msg);
+ Scintilla::Message Find(Scintilla::Keys key, Scintilla::KeyMod modifiers) const; // 0 returned on failure
+ const std::map<KeyModifiers, Scintilla::Message> &GetKeyMap() const noexcept;
};
}
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index 4b9037215..10693c749 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -18,17 +18,19 @@
#include <iterator>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
#include "Geometry.h"
-#include "Platform.h"
-#include "Scintilla.h"
+#include "Platform.h"
#include "XPM.h"
#include "LineMarker.h"
#include "UniConversion.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
LineMarker::LineMarker(const LineMarker &other) {
// Defined to avoid pxpm and image being blindly copied, not as a complete copy constructor.
@@ -74,22 +76,22 @@ LineMarker &LineMarker::operator=(const LineMarker &other) {
}
ColourRGBA LineMarker::BackWithAlpha() const noexcept {
- return ColourRGBA(back, alpha);
+ return ColourRGBA(back, static_cast<int>(alpha));
}
void LineMarker::SetXPM(const char *textForm) {
pxpm = std::make_unique<XPM>(textForm);
- markType = SC_MARK_PIXMAP;
+ markType = MarkerSymbol::Pixmap;
}
void LineMarker::SetXPM(const char *const *linesForm) {
pxpm = std::make_unique<XPM>(linesForm);
- markType = SC_MARK_PIXMAP;
+ markType = MarkerSymbol::Pixmap;
}
void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage) {
image = std::make_unique<RGBAImage>(static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y), scale, pixelsRGBAImage);
- markType = SC_MARK_RGBAIMAGE;
+ markType = MarkerSymbol::RgbaImage;
}
namespace {
@@ -223,41 +225,41 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
switch (markType) {
- case SC_MARK_VLINE:
+ case MarkerSymbol::VLine:
surface->FillRectangle(rcVLine, colourBody);
break;
- case SC_MARK_LCORNER:
+ case MarkerSymbol::LCorner:
surface->FillRectangle(Clamp(rcVLine, Edge::bottom, centre.y + 1.0f), colourTail);
surface->FillRectangle(rcStick, colourTail);
break;
- case SC_MARK_TCORNER:
+ case MarkerSymbol::TCorner:
surface->FillRectangle(Clamp(rcVLine, Edge::bottom, centre.y + 1.0f), colourBody);
surface->FillRectangle(Clamp(rcVLine, Edge::top, centre.y + 1.0f), colourHead);
surface->FillRectangle(rcStick, colourTail);
break;
// CORNERCURVE cases divide slightly lower than CORNER to accommodate the curve
- case SC_MARK_LCORNERCURVE:
+ case MarkerSymbol::LCornerCurve:
surface->FillRectangle(Clamp(rcVLine, Edge::bottom, centre.y), colourTail);
DrawTail(surface, leftLine, rcWhole.right - 1.0f, centre.y - widthStroke,
widthStroke, colourTail);
break;
- case SC_MARK_TCORNERCURVE:
+ case MarkerSymbol::TCornerCurve:
surface->FillRectangle(Clamp(rcVLine, Edge::bottom, centre.y), colourBody);
surface->FillRectangle(Clamp(rcVLine, Edge::top, centre.y), colourHead);
DrawTail(surface, leftLine, rcWhole.right - 1.0f, centre.y - widthStroke,
widthStroke, colourTail);
break;
- case SC_MARK_BOXPLUS:
+ case MarkerSymbol::BoxPlus:
DrawSymbol(surface, Shape::Square, Expansion::Plus, rcSymbol, widthStroke,
fore, colourHead, colourHead, colourTail);
break;
- case SC_MARK_BOXPLUSCONNECTED: {
+ case MarkerSymbol::BoxPlusConnected: {
const ColourRGBA colourBelow = (part == FoldPart::headWithTail) ? colourTail : colourBody;
surface->FillRectangle(rcBelowSymbol, colourBelow);
surface->FillRectangle(rcAboveSymbol, colourBody);
@@ -268,13 +270,13 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
}
break;
- case SC_MARK_BOXMINUS:
+ case MarkerSymbol::BoxMinus:
surface->FillRectangle(rcBelowSymbol, colourHead);
DrawSymbol(surface, Shape::Square, Expansion::Minus, rcSymbol, widthStroke,
fore, colourHead, colourHead, colourTail);
break;
- case SC_MARK_BOXMINUSCONNECTED: {
+ case MarkerSymbol::BoxMinusConnected: {
surface->FillRectangle(rcBelowSymbol, colourHead);
surface->FillRectangle(rcAboveSymbol, colourBody);
@@ -284,12 +286,12 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
}
break;
- case SC_MARK_CIRCLEPLUS:
+ case MarkerSymbol::CirclePlus:
DrawSymbol(surface, Shape::Circle, Expansion::Plus, rcSymbol, widthStroke,
fore, colourHead, colourHead, colourTail);
break;
- case SC_MARK_CIRCLEPLUSCONNECTED: {
+ case MarkerSymbol::CirclePlusConnected: {
const ColourRGBA colourBelow = (part == FoldPart::headWithTail) ? colourTail : colourBody;
surface->FillRectangle(rcBelowSymbol, colourBelow);
surface->FillRectangle(rcAboveSymbol, colourBody);
@@ -300,13 +302,13 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
}
break;
- case SC_MARK_CIRCLEMINUS:
+ case MarkerSymbol::CircleMinus:
surface->FillRectangle(rcBelowSymbol, colourHead);
DrawSymbol(surface, Shape::Circle, Expansion::Minus, rcSymbol, widthStroke,
fore, colourHead, colourHead, colourTail);
break;
- case SC_MARK_CIRCLEMINUSCONNECTED: {
+ case MarkerSymbol::CircleMinusConnected: {
surface->FillRectangle(rcBelowSymbol, colourHead);
surface->FillRectangle(rcAboveSymbol, colourBody);
const ColourRGBA colourRight = (part == FoldPart::body) ? colourTail : colourHead;
@@ -315,6 +317,9 @@ void LineMarker::DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, Fo
}
break;
+ default:
+ break;
+
}
}
@@ -327,7 +332,7 @@ void LineMarker::AlignedPolygon(Surface *surface, const Point *pts, size_t npts)
surface->Polygon(points.data(), std::size(points), FillStroke(back, fore, strokeWidth));
}
-void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, FoldPart part, int marginStyle) const {
+void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, FoldPart part, MarginType marginStyle) const {
// This is to satisfy the changed API - eventually the stroke width will be exposed to clients
if (customDraw) {
@@ -335,11 +340,11 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
return;
}
- if ((markType == SC_MARK_PIXMAP) && (pxpm)) {
+ if ((markType == MarkerSymbol::Pixmap) && (pxpm)) {
pxpm->Draw(surface, rcWhole);
return;
}
- if ((markType == SC_MARK_RGBAIMAGE) && (image)) {
+ if ((markType == MarkerSymbol::RgbaImage) && (image)) {
// Make rectangle just large enough to fit image centred on centre of rcWhole
PRectangle rcImage;
rcImage.top = ((rcWhole.top + rcWhole.bottom) - image->GetScaledHeight()) / 2;
@@ -350,7 +355,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
return;
}
- if ((markType >= SC_MARK_VLINE) && markType <= (SC_MARK_CIRCLEMINUSCONNECTED)) {
+ if ((markType >= MarkerSymbol::VLine) && markType <= (MarkerSymbol::CircleMinusConnected)) {
DrawFoldingMark(surface, rcWhole, part);
return;
}
@@ -366,13 +371,13 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
const XYPOSITION dimOn2 = std::floor(minDim / 2);
const XYPOSITION dimOn4 = std::floor(minDim / 4);
const XYPOSITION armSize = dimOn2 - 2;
- if (marginStyle == SC_MARGIN_NUMBER || marginStyle == SC_MARGIN_TEXT || marginStyle == SC_MARGIN_RTEXT) {
+ if (marginStyle == MarginType::Number || marginStyle == MarginType::Text || marginStyle == MarginType::RText) {
// On textual margins move marker to the left to try to avoid overlapping the text
centreX = rcWhole.left + dimOn2 + 1;
}
switch (markType) {
- case SC_MARK_ROUNDRECT: {
+ case MarkerSymbol::RoundRect: {
PRectangle rcRounded = rc;
rcRounded.left = rc.left + 1;
rcRounded.right = rc.right - 1;
@@ -380,7 +385,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_CIRCLE: {
+ case MarkerSymbol::Circle: {
const PRectangle rcCircle = PRectangle(
centreX - dimOn2,
centreY - dimOn2,
@@ -390,7 +395,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_ARROW: {
+ case MarkerSymbol::Arrow: {
Point pts[] = {
Point(centreX - dimOn4, centreY - dimOn2),
Point(centreX - dimOn4, centreY + dimOn2),
@@ -400,7 +405,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_ARROWDOWN: {
+ case MarkerSymbol::ArrowDown: {
Point pts[] = {
Point(centreX - dimOn2, centreY - dimOn4),
Point(centreX + dimOn2, centreY - dimOn4),
@@ -410,7 +415,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_PLUS: {
+ case MarkerSymbol::Plus: {
Point pts[] = {
Point(centreX - armSize, centreY - 1),
Point(centreX - 1, centreY - 1),
@@ -429,7 +434,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_MINUS: {
+ case MarkerSymbol::Minus: {
Point pts[] = {
Point(centreX - armSize, centreY - 1),
Point(centreX + armSize, centreY - 1),
@@ -440,7 +445,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_SMALLRECT: {
+ case MarkerSymbol::SmallRect: {
PRectangle rcSmall;
rcSmall.left = rc.left + 1;
rcSmall.top = rc.top + 2;
@@ -450,14 +455,14 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_EMPTY:
- case SC_MARK_BACKGROUND:
- case SC_MARK_UNDERLINE:
- case SC_MARK_AVAILABLE:
+ case MarkerSymbol::Empty:
+ case MarkerSymbol::Background:
+ case MarkerSymbol::Underline:
+ case MarkerSymbol::Available:
// An invisible marker so don't draw anything
break;
- case SC_MARK_DOTDOTDOT: {
+ case MarkerSymbol::DotDotDot: {
XYPOSITION right = static_cast<XYPOSITION>(centreX - 6);
for (int b = 0; b < 3; b++) {
const PRectangle rcBlob(right, rc.bottom - 4, right + 2, rc.bottom - 2);
@@ -467,7 +472,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_ARROWS: {
+ case MarkerSymbol::Arrows: {
XYPOSITION right = centreX - 4.0f + strokeWidth / 2.0f;
const XYPOSITION midY = centreY + strokeWidth / 2.0f;
const XYPOSITION armLength = std::round(dimOn2 - strokeWidth);
@@ -483,7 +488,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_SHORTARROW: {
+ case MarkerSymbol::ShortArrow: {
Point pts[] = {
Point(centreX, centreY + dimOn2),
Point(centreX + dimOn2, centreY),
@@ -498,18 +503,18 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_FULLRECT:
+ case MarkerSymbol::FullRect:
surface->FillRectangle(rcWhole, back);
break;
- case SC_MARK_LEFTRECT: {
+ case MarkerSymbol::LeftRect: {
PRectangle rcLeft = rcWhole;
rcLeft.right = rcLeft.left + 4;
surface->FillRectangle(rcLeft, back);
}
break;
- case SC_MARK_BOOKMARK: {
+ case MarkerSymbol::Bookmark: {
const XYPOSITION halfHeight = std::floor(minDim / 3);
Point pts[] = {
Point(rcWhole.left, centreY - halfHeight),
@@ -522,7 +527,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
}
break;
- case SC_MARK_VERTICALBOOKMARK: {
+ case MarkerSymbol::VerticalBookmark: {
const XYPOSITION halfWidth = std::floor(minDim / 3);
Point pts[] = {
Point(centreX - halfWidth, centreY - dimOn2),
@@ -536,9 +541,10 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
break;
default:
- if (markType >= SC_MARK_CHARACTER) {
+ if (markType >= MarkerSymbol::Character) {
char character[UTF8MaxBytes + 1];
- UTF8FromUTF32Character(markType - SC_MARK_CHARACTER, character);
+ const int uch = static_cast<int>(markType) - static_cast<int>(MarkerSymbol::Character);
+ UTF8FromUTF32Character(uch, character);
const XYPOSITION width = surface->WidthTextUTF8(fontForCharacter, character);
PRectangle rcText = rc;
rcText.left += (rc.Width() - width) / 2;
@@ -546,7 +552,7 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f
surface->DrawTextNoClipUTF8(rcText, fontForCharacter, rcText.bottom - 2,
character, fore, back);
} else {
- // treat as SC_MARK_FULLRECT
+ // treat as MarkerSymbol::FullRect
surface->FillRectangle(rcWhole, back);
}
break;
diff --git a/src/LineMarker.h b/src/LineMarker.h
index e0c4100a5..0a60da962 100644
--- a/src/LineMarker.h
+++ b/src/LineMarker.h
@@ -8,14 +8,12 @@
#ifndef LINEMARKER_H
#define LINEMARKER_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class XPM;
class RGBAImage;
-typedef void (*DrawLineMarkerFn)(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, int tFold, int marginStyle, const void *lineMarker);
-
-enum class Layer { base = 0, under = 1, over = 2 };
+typedef void (*DrawLineMarkerFn)(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, int tFold, Scintilla::MarginType marginStyle, const void *lineMarker);
/**
*/
@@ -23,12 +21,12 @@ class LineMarker {
public:
enum class FoldPart { undefined, head, body, tail, headWithTail };
- int markType = SC_MARK_CIRCLE;
+ Scintilla::MarkerSymbol markType = Scintilla::MarkerSymbol::Circle;
ColourRGBA fore = ColourRGBA(0, 0, 0);
ColourRGBA back = ColourRGBA(0xff, 0xff, 0xff);
ColourRGBA backSelected = ColourRGBA(0xff, 0x00, 0x00);
- Layer layer = Layer::base;
- int alpha = SC_ALPHA_NOALPHA;
+ Scintilla::Layer layer = Scintilla::Layer::Base;
+ Scintilla::Alpha alpha = Scintilla::Alpha::NoAlpha;
XYPOSITION strokeWidth = 1.0f;
std::unique_ptr<XPM> pxpm;
std::unique_ptr<RGBAImage> image;
@@ -51,7 +49,7 @@ public:
void SetXPM(const char *const *linesForm);
void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage);
void AlignedPolygon(Surface *surface, const Point *pts, size_t npts) const;
- void Draw(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, FoldPart part, int marginStyle) const;
+ void Draw(Surface *surface, const PRectangle &rcWhole, const Font *fontForCharacter, FoldPart part, Scintilla::MarginType marginStyle) const;
void DrawFoldingMark(Surface *surface, const PRectangle &rcWhole, FoldPart part) const;
};
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);
}
}
diff --git a/src/MarginView.h b/src/MarginView.h
index 054765a02..f73a18858 100644
--- a/src/MarginView.h
+++ b/src/MarginView.h
@@ -8,7 +8,7 @@
#ifndef MARGINVIEW_H
#define MARGINVIEW_H
-namespace Scintilla {
+namespace Scintilla::Internal {
void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourRGBA wrapColour);
diff --git a/src/Partitioning.h b/src/Partitioning.h
index 195daae9b..cf1bb6a7b 100644
--- a/src/Partitioning.h
+++ b/src/Partitioning.h
@@ -8,7 +8,7 @@
#ifndef PARTITIONING_H
#define PARTITIONING_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/// A split vector of integers with a method for adding a value to all elements
/// in a range.
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index 91621a4b4..068d5d0a5 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -17,18 +17,19 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "CellBuffer.h"
#include "PerLine.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
MarkerHandleSet::MarkerHandleSet() {
}
@@ -227,14 +228,14 @@ void LineLevels::Init() {
void LineLevels::InsertLine(Sci::Line line) {
if (levels.Length()) {
- const int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE;
+ const int level = (line < levels.Length()) ? levels[line] : static_cast<int>(Scintilla::FoldLevel::Base);
levels.Insert(line, level);
}
}
void LineLevels::InsertLines(Sci::Line line, Sci::Line lines) {
if (levels.Length()) {
- const int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE;
+ const int level = (line < levels.Length()) ? levels[line] : static_cast<int>(Scintilla::FoldLevel::Base);
levels.InsertValue(line, lines, level);
}
}
@@ -243,17 +244,17 @@ void LineLevels::RemoveLine(Sci::Line line) {
if (levels.Length()) {
// Move up following lines but merge header flag from this line
// to line before to avoid a temporary disappearance causing expansion.
- int firstHeader = levels[line] & SC_FOLDLEVELHEADERFLAG;
+ int firstHeader = levels[line] & static_cast<int>(Scintilla::FoldLevel::HeaderFlag);
levels.Delete(line);
if (line == levels.Length()-1) // Last line loses the header flag
- levels[line-1] &= ~SC_FOLDLEVELHEADERFLAG;
+ levels[line-1] &= ~static_cast<int>(Scintilla::FoldLevel::HeaderFlag);
else if (line > 0)
levels[line-1] |= firstHeader;
}
}
void LineLevels::ExpandLevels(Sci::Line sizeNew) {
- levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE);
+ levels.InsertValue(levels.Length(), sizeNew - levels.Length(), static_cast<int>(Scintilla::FoldLevel::Base));
}
void LineLevels::ClearLevels() {
@@ -278,7 +279,7 @@ int LineLevels::GetLevel(Sci::Line line) const noexcept {
if (levels.Length() && (line >= 0) && (line < levels.Length())) {
return levels[line];
} else {
- return SC_FOLDLEVELBASE;
+ return static_cast<int>(Scintilla::FoldLevel::Base);
}
}
diff --git a/src/PerLine.h b/src/PerLine.h
index b43b0a18b..8f88183f1 100644
--- a/src/PerLine.h
+++ b/src/PerLine.h
@@ -8,7 +8,7 @@
#ifndef PERLINE_H
#define PERLINE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
* This holds the marker identifier and the marker type to display.
diff --git a/src/Platform.h b/src/Platform.h
index f279b80cd..3f25f343f 100644
--- a/src/Platform.h
+++ b/src/Platform.h
@@ -76,7 +76,7 @@
#endif
-namespace Scintilla {
+namespace Scintilla::Internal {
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
@@ -97,21 +97,21 @@ constexpr const char *localeNameDefault = "en-us";
struct FontParameters {
const char *faceName;
XYPOSITION size;
- int weight;
+ Scintilla::FontWeight weight;
bool italic;
- int extraFontFlag;
- int technology;
- int characterSet;
+ Scintilla::FontQuality extraFontFlag;
+ Scintilla::Technology technology;
+ Scintilla::CharacterSet characterSet;
const char *localeName;
constexpr FontParameters(
const char *faceName_,
XYPOSITION size_=10,
- int weight_=400,
+ Scintilla::FontWeight weight_= Scintilla::FontWeight::Normal,
bool italic_=false,
- int extraFontFlag_=0,
- int technology_=0,
- int characterSet_=0,
+ Scintilla::FontQuality extraFontFlag_= Scintilla::FontQuality::QualityDefault,
+ Scintilla::Technology technology_= Scintilla::Technology::Default,
+ Scintilla::CharacterSet characterSet_= Scintilla::CharacterSet::Ansi,
const char *localeName_=localeNameDefault) noexcept :
faceName(faceName_),
@@ -184,7 +184,7 @@ public:
Surface &operator=(const Surface &) = delete;
Surface &operator=(Surface &&) = delete;
virtual ~Surface() noexcept = default;
- static std::unique_ptr<Surface> Allocate(int technology);
+ static std::unique_ptr<Surface> Allocate(Scintilla::Technology technology);
virtual void Init(WindowID wid)=0;
virtual void Init(SurfaceID sid, WindowID wid)=0;
@@ -201,7 +201,7 @@ public:
};
virtual void Release() noexcept=0;
- virtual int Supports(int feature) noexcept=0;
+ virtual int SupportsFeature(Scintilla::Supports feature) noexcept=0;
virtual bool Initialised()=0;
virtual int LogPixelsY()=0;
virtual int PixelDivisions()=0;
@@ -317,7 +317,7 @@ public:
static std::unique_ptr<ListBox> Allocate();
virtual void SetFont(const Font *font)=0;
- virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0;
+ virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, Scintilla::Technology technology_)=0;
virtual void SetAverageCharWidth(int width)=0;
virtual void SetVisibleRows(int rows)=0;
virtual int GetVisibleRows() const=0;
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 1839f2072..fb3d8fa01 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -21,14 +21,15 @@
#include <iterator>
#include <memory>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.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"
@@ -51,6 +52,7 @@
#include "PositionCache.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
void BidiData::Resize(size_t maxLineLength_) {
stylesFonts.resize(maxLineLength_ + 1);
@@ -134,7 +136,7 @@ int LineLayout::LineStart(int line) const noexcept {
}
}
-int Scintilla::LineLayout::LineLength(int line) const noexcept {
+int LineLayout::LineLength(int line) const noexcept {
if (!lineStarts) {
return numCharsInLine;
} if (line >= lines - 1) {
@@ -361,7 +363,7 @@ XYPOSITION ScreenLine::TabPositionAfter(XYPOSITION xPosition) const {
}
LineLayoutCache::LineLayoutCache() :
- level(Cache::none),
+ level(LineCache::None),
allInvalidated(false), styleClock(-1) {
}
@@ -380,13 +382,13 @@ constexpr size_t alignmentLLC = 20;
size_t LineLayoutCache::EntryForLine(Sci::Line line) const noexcept {
switch (level) {
- case Cache::none:
+ case LineCache::None:
return 0;
- case Cache::caret:
+ case LineCache::Caret:
return 0;
- case Cache::page:
+ case LineCache::Page:
return 1 + (line % (cache.size() - 1));
- case Cache::document:
+ case LineCache::Document:
return line;
}
return 0;
@@ -394,11 +396,11 @@ size_t LineLayoutCache::EntryForLine(Sci::Line line) const noexcept {
void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc) {
size_t lengthForLevel = 0;
- if (level == Cache::caret) {
+ if (level == LineCache::Caret) {
lengthForLevel = 1;
- } else if (level == Cache::page) {
+ } else if (level == LineCache::Page) {
lengthForLevel = AlignUp(linesOnScreen + 1, alignmentLLC);
- } else if (level == Cache::document) {
+ } else if (level == LineCache::Document) {
lengthForLevel = AlignUp(linesInDoc, alignmentLLC);
}
@@ -408,7 +410,7 @@ void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesI
// Cache::none -> no entries
// Cache::caret -> 1 entry can take any line
// Cache::document -> entry per line so each line in correct entry after resize
- if (level == Cache::page) {
+ if (level == LineCache::Page) {
// Cache::page -> locates lines in particular entries which may be incorrect after
// a resize so move them to correct entries.
for (size_t i = 1; i < cache.size();) {
@@ -462,7 +464,7 @@ void LineLayoutCache::Invalidate(LineLayout::ValidLevel validity_) noexcept {
}
}
-void LineLayoutCache::SetLevel(Cache level_) noexcept {
+void LineLayoutCache::SetLevel(LineCache level_) noexcept {
if (level != level_) {
level = level_;
allInvalidated = false;
@@ -479,7 +481,7 @@ std::shared_ptr<LineLayout> LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci:
}
allInvalidated = false;
size_t pos = 0;
- if (level == Cache::page) {
+ if (level == LineCache::Page) {
// If first entry is this line then just reuse it.
if (!(cache[0] && (cache[0]->lineNumber == lineNumber))) {
const size_t posForLine = EntryForLine(lineNumber);
@@ -503,7 +505,7 @@ std::shared_ptr<LineLayout> LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci:
pos = posForLine;
}
}
- } else if (level == Cache::document) {
+ } else if (level == LineCache::Document) {
pos = lineNumber;
}
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 4c62900e8..16ac42ef8 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -8,7 +8,7 @@
#ifndef POSITIONCACHE_H
#define POSITIONCACHE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
inline constexpr bool IsEOLChar(int ch) noexcept {
return (ch == '\r') || (ch == '\n');
@@ -151,14 +151,8 @@ struct ScreenLine : public IScreenLine {
*/
class LineLayoutCache {
public:
- enum class Cache {
- none = SC_CACHE_NONE,
- caret = SC_CACHE_CARET,
- page = SC_CACHE_PAGE,
- document = SC_CACHE_DOCUMENT
- };
private:
- Cache level;
+ Scintilla::LineCache level;
std::vector<std::shared_ptr<LineLayout>>cache;
bool allInvalidated;
int styleClock;
@@ -174,8 +168,8 @@ public:
virtual ~LineLayoutCache();
void Deallocate() noexcept;
void Invalidate(LineLayout::ValidLevel validity_) noexcept;
- void SetLevel(Cache level_) noexcept;
- Cache GetLevel() const noexcept { return level; }
+ void SetLevel(Scintilla::LineCache level_) noexcept;
+ Scintilla::LineCache GetLevel() const noexcept { return level; }
std::shared_ptr<LineLayout> Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_,
Sci::Line linesOnScreen, Sci::Line linesInDoc);
};
diff --git a/src/RESearch.cxx b/src/RESearch.cxx
index 54815d0a3..6d30e4c6b 100644
--- a/src/RESearch.cxx
+++ b/src/RESearch.cxx
@@ -212,7 +212,7 @@
#include "CharClassify.h"
#include "RESearch.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
#define OKP 1
#define NOP 0
diff --git a/src/RESearch.h b/src/RESearch.h
index 49bfc0541..4f0598826 100644
--- a/src/RESearch.h
+++ b/src/RESearch.h
@@ -9,7 +9,7 @@
#ifndef RESEARCH_H
#define RESEARCH_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class CharacterIndexer {
public:
diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx
index 11bab25bd..e9d3f6e4e 100644
--- a/src/RunStyles.cxx
+++ b/src/RunStyles.cxx
@@ -21,13 +21,12 @@
#include "Debugging.h"
-#include "Scintilla.h"
#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Find the first run at a position
template <typename DISTANCE, typename STYLE>
@@ -308,9 +307,9 @@ void RunStyles<DISTANCE, STYLE>::Check() const {
}
}
-template class Scintilla::RunStyles<int, int>;
-template class Scintilla::RunStyles<int, char>;
+template class Scintilla::Internal::RunStyles<int, int>;
+template class Scintilla::Internal::RunStyles<int, char>;
#if (PTRDIFF_MAX != INT_MAX) || PLAT_HAIKU
-template class Scintilla::RunStyles<ptrdiff_t, int>;
-template class Scintilla::RunStyles<ptrdiff_t, char>;
+template class Scintilla::Internal::RunStyles<ptrdiff_t, int>;
+template class Scintilla::Internal::RunStyles<ptrdiff_t, char>;
#endif
diff --git a/src/RunStyles.h b/src/RunStyles.h
index 97673d04b..328fa1d4d 100644
--- a/src/RunStyles.h
+++ b/src/RunStyles.h
@@ -10,7 +10,7 @@
#ifndef RUNSTYLES_H
#define RUNSTYLES_H
-namespace Scintilla {
+namespace Scintilla::Internal {
// Return for RunStyles::FillRange reports if anything was changed and the
// range that was changed. This may be trimmed from the requested range
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 4c1e9a803..a6e769d81 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -20,14 +20,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"
@@ -57,12 +59,13 @@
#include "ScintillaBase.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
ScintillaBase::ScintillaBase() {
- displayPopupMenu = SC_POPUP_ALL;
+ displayPopupMenu = PopUp::All;
listType = 0;
maxListWidth = 0;
- multiAutoCMode = SC_MULTIAUTOC_ONCE;
+ multiAutoCMode = MultiAutoComplete::Once;
}
ScintillaBase::~ScintillaBase() {
@@ -101,73 +104,73 @@ void ScintillaBase::Command(int cmdId) {
break;
case idcmdUndo:
- WndProc(SCI_UNDO, 0, 0);
+ WndProc(Message::Undo, 0, 0);
break;
case idcmdRedo:
- WndProc(SCI_REDO, 0, 0);
+ WndProc(Message::Redo, 0, 0);
break;
case idcmdCut:
- WndProc(SCI_CUT, 0, 0);
+ WndProc(Message::Cut, 0, 0);
break;
case idcmdCopy:
- WndProc(SCI_COPY, 0, 0);
+ WndProc(Message::Copy, 0, 0);
break;
case idcmdPaste:
- WndProc(SCI_PASTE, 0, 0);
+ WndProc(Message::Paste, 0, 0);
break;
case idcmdDelete:
- WndProc(SCI_CLEAR, 0, 0);
+ WndProc(Message::Clear, 0, 0);
break;
case idcmdSelectAll:
- WndProc(SCI_SELECTALL, 0, 0);
+ WndProc(Message::SelectAll, 0, 0);
break;
}
}
-int ScintillaBase::KeyCommand(unsigned int iMessage) {
+int ScintillaBase::KeyCommand(Message iMessage) {
// Most key commands cancel autocompletion mode
if (ac.Active()) {
switch (iMessage) {
// Except for these
- case SCI_LINEDOWN:
+ case Message::LineDown:
AutoCompleteMove(1);
return 0;
- case SCI_LINEUP:
+ case Message::LineUp:
AutoCompleteMove(-1);
return 0;
- case SCI_PAGEDOWN:
+ case Message::PageDown:
AutoCompleteMove(ac.lb->GetVisibleRows());
return 0;
- case SCI_PAGEUP:
+ case Message::PageUp:
AutoCompleteMove(-ac.lb->GetVisibleRows());
return 0;
- case SCI_VCHOME:
+ case Message::VCHome:
AutoCompleteMove(-5000);
return 0;
- case SCI_LINEEND:
+ case Message::LineEnd:
AutoCompleteMove(5000);
return 0;
- case SCI_DELETEBACK:
+ case Message::DeleteBack:
DelCharBack(true);
AutoCompleteCharacterDeleted();
EnsureCaretVisible();
return 0;
- case SCI_DELETEBACKNOTLINE:
+ case Message::DeleteBackNotLine:
DelCharBack(false);
AutoCompleteCharacterDeleted();
EnsureCaretVisible();
return 0;
- case SCI_TAB:
- AutoCompleteCompleted(0, SC_AC_TAB);
+ case Message::Tab:
+ AutoCompleteCompleted(0, CompletionMethods::Tab);
return 0;
- case SCI_NEWLINE:
- AutoCompleteCompleted(0, SC_AC_NEWLINE);
+ case Message::NewLine:
+ AutoCompleteCompleted(0, CompletionMethods::Newline);
return 0;
default:
@@ -177,17 +180,17 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
if (ct.inCallTipMode) {
if (
- (iMessage != SCI_CHARLEFT) &&
- (iMessage != SCI_CHARLEFTEXTEND) &&
- (iMessage != SCI_CHARRIGHT) &&
- (iMessage != SCI_CHARRIGHTEXTEND) &&
- (iMessage != SCI_EDITTOGGLEOVERTYPE) &&
- (iMessage != SCI_DELETEBACK) &&
- (iMessage != SCI_DELETEBACKNOTLINE)
+ (iMessage != Message::CharLeft) &&
+ (iMessage != Message::CharLeftExtend) &&
+ (iMessage != Message::CharRight) &&
+ (iMessage != Message::CharRightExtend) &&
+ (iMessage != Message::EditToggleOvertype) &&
+ (iMessage != Message::DeleteBack) &&
+ (iMessage != Message::DeleteBackNotLine)
) {
ct.CallTipCancel();
}
- if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
+ if ((iMessage == Message::DeleteBack) || (iMessage == Message::DeleteBackNotLine)) {
if (sel.MainCaret() <= ct.posStartCallTip) {
ct.CallTipCancel();
}
@@ -202,19 +205,19 @@ void ScintillaBase::ListNotify(ListBoxEvent *plbe) {
AutoCompleteSelection();
break;
case ListBoxEvent::EventType::doubleClick:
- AutoCompleteCompleted(0, SC_AC_DOUBLECLICK);
+ AutoCompleteCompleted(0, CompletionMethods::DoubleClick);
break;
}
}
void ScintillaBase::AutoCompleteInsert(Sci::Position startPos, Sci::Position removeLen, const char *text, Sci::Position textLen) {
UndoGroup ug(pdoc);
- if (multiAutoCMode == SC_MULTIAUTOC_ONCE) {
+ if (multiAutoCMode == MultiAutoComplete::Once) {
pdoc->DeleteChars(startPos, removeLen);
const Sci::Position lengthInserted = pdoc->InsertString(startPos, text, textLen);
SetEmptySelection(startPos + lengthInserted);
} else {
- // SC_MULTIAUTOC_EACH
+ // MultiAutoComplete::Each
for (size_t r=0; r<sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
@@ -258,10 +261,10 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list
lenEntered, vs.lineHeight, IsUnicodeMode(), technology);
ListOptions options{
- vs.ElementColour(SC_ELEMENT_LIST),
- vs.ElementColour(SC_ELEMENT_LIST_BACK),
- vs.ElementColour(SC_ELEMENT_LIST_SELECTED),
- vs.ElementColour(SC_ELEMENT_LIST_SELECTED_BACK)
+ vs.ElementColour(Element::List),
+ vs.ElementColour(Element::ListBack),
+ vs.ElementColour(Element::ListSelected),
+ vs.ElementColour(Element::ListSelectedBack)
};
ac.lb->SetOptions(options);
@@ -296,8 +299,8 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list
rcac.right = rcac.left + widthLB;
rcac.bottom = static_cast<XYPOSITION>(std::min(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom)));
ac.lb->SetPositionRelative(rcac, &wMain);
- ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font.get());
- const unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth);
+ ac.lb->SetFont(vs.styles[StyleDefault].font.get());
+ const unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[StyleDefault].aveCharWidth);
ac.lb->SetAverageCharWidth(aveCharWidth);
ac.lb->SetDelegate(this);
@@ -328,8 +331,8 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list
void ScintillaBase::AutoCompleteCancel() {
if (ac.Active()) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_AUTOCCANCELLED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::AutoCCancelled;
scn.wParam = 0;
scn.listType = 0;
NotifyParent(scn);
@@ -353,9 +356,9 @@ void ScintillaBase::AutoCompleteSelection() {
selected = ac.GetValue(item);
}
- SCNotification scn = {};
- scn.nmhdr.code = SCN_AUTOCSELECTIONCHANGE;
- scn.message = 0;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::AutoCSelectionChange;
+ scn.message = static_cast<Message>(0);
scn.wParam = listType;
scn.listType = listType;
const Sci::Position firstPos = ac.posStart - ac.startLen;
@@ -367,7 +370,7 @@ void ScintillaBase::AutoCompleteSelection() {
void ScintillaBase::AutoCompleteCharacterAdded(char ch) {
if (ac.IsFillUpChar(ch)) {
- AutoCompleteCompleted(ch, SC_AC_FILLUP);
+ AutoCompleteCompleted(ch, CompletionMethods::FillUp);
} else if (ac.IsStopChar(ch)) {
AutoCompleteCancel();
} else {
@@ -383,14 +386,14 @@ void ScintillaBase::AutoCompleteCharacterDeleted() {
} else {
AutoCompleteMoveToCurrentWord();
}
- SCNotification scn = {};
- scn.nmhdr.code = SCN_AUTOCCHARDELETED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::AutoCCharDeleted;
scn.wParam = 0;
scn.listType = 0;
NotifyParent(scn);
}
-void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod) {
+void ScintillaBase::AutoCompleteCompleted(char ch, CompletionMethods completionMethod) {
const int item = ac.GetSelection();
if (item == -1) {
AutoCompleteCancel();
@@ -400,9 +403,9 @@ void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod
ac.Show(false);
- SCNotification scn = {};
- scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION;
- scn.message = 0;
+ NotificationData scn = {};
+ scn.nmhdr.code = listType > 0 ? Notification::UserListSelection : Notification::AutoCSelection;
+ scn.message = static_cast<Message>(0);
scn.ch = ch;
scn.listCompletionMethod = completionMethod;
scn.wParam = listType;
@@ -428,7 +431,7 @@ void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod
AutoCompleteInsert(firstPos, endPos - firstPos, selected.c_str(), selected.length());
SetLastXChosen();
- scn.nmhdr.code = SCN_AUTOCCOMPLETED;
+ scn.nmhdr.code = Notification::AutoCCompleted;
NotifyParent(scn);
}
@@ -456,12 +459,12 @@ int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) const {
void ScintillaBase::CallTipShow(Point pt, const char *defn) {
ac.Cancel();
- // If container knows about STYLE_CALLTIP then use it in place of the
- // STYLE_DEFAULT for the face name, size and character set. Also use it
+ // If container knows about StyleCallTip then use it in place of the
+ // StyleDefault for the face name, size and character set. Also use it
// for the foreground and background colour.
- const int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT;
+ const int ctStyle = ct.UseStyleCallTip() ? StyleCallTip : StyleDefault;
if (ct.UseStyleCallTip()) {
- ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);
+ ct.SetForeBack(vs.styles[StyleCallTip].fore, vs.styles[StyleCallTip].back);
}
if (wMargin.Created()) {
pt = pt + GetVisibleOriginInMain();
@@ -497,27 +500,27 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
}
void ScintillaBase::CallTipClick() {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_CALLTIPCLICK;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::CallTipClick;
scn.position = ct.clickPlace;
NotifyParent(scn);
}
bool ScintillaBase::ShouldDisplayPopup(Point ptInWindowCoordinates) const {
- return (displayPopupMenu == SC_POPUP_ALL ||
- (displayPopupMenu == SC_POPUP_TEXT && !PointInSelMargin(ptInWindowCoordinates)));
+ return (displayPopupMenu == PopUp::All ||
+ (displayPopupMenu == PopUp::Text && !PointInSelMargin(ptInWindowCoordinates)));
}
void ScintillaBase::ContextMenu(Point pt) {
- if (displayPopupMenu) {
- const bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
+ if (displayPopupMenu != PopUp::Never) {
+ const bool writable = !WndProc(Message::GetReadOnly, 0, 0);
popup.CreatePopUp();
AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo());
AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo());
AddToPopUp("");
AddToPopUp("Cut", idcmdCut, writable && !sel.Empty());
AddToPopUp("Copy", idcmdCopy, !sel.Empty());
- AddToPopUp("Paste", idcmdPaste, writable && WndProc(SCI_CANPASTE, 0, 0));
+ AddToPopUp("Paste", idcmdPaste, writable && WndProc(Message::CanPaste, 0, 0));
AddToPopUp("Delete", idcmdDelete, writable && !sel.Empty());
AddToPopUp("");
AddToPopUp("Select All", idcmdSelectAll);
@@ -531,17 +534,17 @@ void ScintillaBase::CancelModes() {
Editor::CancelModes();
}
-void ScintillaBase::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) {
+void ScintillaBase::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) {
CancelModes();
Editor::ButtonDownWithModifiers(pt, curTime, modifiers);
}
-void ScintillaBase::RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) {
+void ScintillaBase::RightButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) {
CancelModes();
Editor::RightButtonDownWithModifiers(pt, curTime, modifiers);
}
-namespace Scintilla {
+namespace Scintilla::Internal {
class LexState : public LexInterface {
public:
@@ -560,14 +563,14 @@ public:
const char *GetName() const;
void *PrivateCall(int operation, void *pointer);
const char *PropertyNames();
- int PropertyType(const char *name);
+ TypeProperty PropertyType(const char *name);
const char *DescribeProperty(const char *name);
void PropSet(const char *key, const char *val);
const char *PropGet(const char *key) const;
int PropGetInt(const char *key, int defaultValue=0) const;
size_t PropGetExpanded(const char *key, char *result) const;
- int LineEndTypesSupported() override;
+ LineEndType LineEndTypesSupported() override;
int AllocateSubStyles(int styleBase, int numberStyles);
int SubStylesStart(int styleBase);
int SubStylesLength(int styleBase);
@@ -666,11 +669,11 @@ const char *LexState::PropertyNames() {
}
}
-int LexState::PropertyType(const char *name) {
+TypeProperty LexState::PropertyType(const char *name) {
if (instance) {
- return instance->PropertyType(name);
+ return static_cast<TypeProperty>(instance->PropertyType(name));
} else {
- return SC_TYPE_BOOLEAN;
+ return TypeProperty::Boolean;
}
}
@@ -722,11 +725,11 @@ size_t LexState::PropGetExpanded(const char *key, char *result) const {
return 0;
}
-int LexState::LineEndTypesSupported() {
+LineEndType LexState::LineEndTypesSupported() {
if (instance) {
- return instance->LineEndTypesSupported();
+ return static_cast<LineEndType>(instance->LineEndTypesSupported());
}
- return 0;
+ return LineEndType::Default;
}
int LexState::AllocateSubStyles(int styleBase, int numberStyles) {
@@ -839,209 +842,209 @@ void ScintillaBase::NotifyLexerChanged(Document *, void *) {
vs.EnsureStyle(0xff);
}
-sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+sptr_t ScintillaBase::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
switch (iMessage) {
- case SCI_AUTOCSHOW:
+ case Message::AutoCShow:
listType = 0;
AutoCompleteStart(static_cast<Sci::Position>(wParam), ConstCharPtrFromSPtr(lParam));
break;
- case SCI_AUTOCCANCEL:
+ case Message::AutoCCancel:
ac.Cancel();
break;
- case SCI_AUTOCACTIVE:
+ case Message::AutoCActive:
return ac.Active();
- case SCI_AUTOCPOSSTART:
+ case Message::AutoCPosStart:
return ac.posStart;
- case SCI_AUTOCCOMPLETE:
- AutoCompleteCompleted(0, SC_AC_COMMAND);
+ case Message::AutoCComplete:
+ AutoCompleteCompleted(0, CompletionMethods::Command);
break;
- case SCI_AUTOCSETSEPARATOR:
+ case Message::AutoCSetSeparator:
ac.SetSeparator(static_cast<char>(wParam));
break;
- case SCI_AUTOCGETSEPARATOR:
+ case Message::AutoCGetSeparator:
return ac.GetSeparator();
- case SCI_AUTOCSTOPS:
+ case Message::AutoCStops:
ac.SetStopChars(ConstCharPtrFromSPtr(lParam));
break;
- case SCI_AUTOCSELECT:
+ case Message::AutoCSelect:
ac.Select(ConstCharPtrFromSPtr(lParam));
break;
- case SCI_AUTOCGETCURRENT:
+ case Message::AutoCGetCurrent:
return AutoCompleteGetCurrent();
- case SCI_AUTOCGETCURRENTTEXT:
+ case Message::AutoCGetCurrentText:
return AutoCompleteGetCurrentText(CharPtrFromSPtr(lParam));
- case SCI_AUTOCSETCANCELATSTART:
+ case Message::AutoCSetCancelAtStart:
ac.cancelAtStartPos = wParam != 0;
break;
- case SCI_AUTOCGETCANCELATSTART:
+ case Message::AutoCGetCancelAtStart:
return ac.cancelAtStartPos;
- case SCI_AUTOCSETFILLUPS:
+ case Message::AutoCSetFillUps:
ac.SetFillUpChars(ConstCharPtrFromSPtr(lParam));
break;
- case SCI_AUTOCSETCHOOSESINGLE:
+ case Message::AutoCSetChooseSingle:
ac.chooseSingle = wParam != 0;
break;
- case SCI_AUTOCGETCHOOSESINGLE:
+ case Message::AutoCGetChooseSingle:
return ac.chooseSingle;
- case SCI_AUTOCSETIGNORECASE:
+ case Message::AutoCSetIgnoreCase:
ac.ignoreCase = wParam != 0;
break;
- case SCI_AUTOCGETIGNORECASE:
+ case Message::AutoCGetIgnoreCase:
return ac.ignoreCase;
- case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR:
- ac.ignoreCaseBehaviour = static_cast<unsigned int>(wParam);
+ case Message::AutoCSetCaseInsensitiveBehaviour:
+ ac.ignoreCaseBehaviour = static_cast<CaseInsensitiveBehaviour>(wParam);
break;
- case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR:
- return ac.ignoreCaseBehaviour;
+ case Message::AutoCGetCaseInsensitiveBehaviour:
+ return static_cast<sptr_t>(ac.ignoreCaseBehaviour);
- case SCI_AUTOCSETMULTI:
- multiAutoCMode = static_cast<int>(wParam);
+ case Message::AutoCSetMulti:
+ multiAutoCMode = static_cast<MultiAutoComplete>(wParam);
break;
- case SCI_AUTOCGETMULTI:
- return multiAutoCMode;
+ case Message::AutoCGetMulti:
+ return static_cast<sptr_t>(multiAutoCMode);
- case SCI_AUTOCSETORDER:
- ac.autoSort = static_cast<int>(wParam);
+ case Message::AutoCSetOrder:
+ ac.autoSort = static_cast<Ordering>(wParam);
break;
- case SCI_AUTOCGETORDER:
- return ac.autoSort;
+ case Message::AutoCGetOrder:
+ return static_cast<sptr_t>(ac.autoSort);
- case SCI_USERLISTSHOW:
+ case Message::UserListShow:
listType = static_cast<int>(wParam);
AutoCompleteStart(0, ConstCharPtrFromSPtr(lParam));
break;
- case SCI_AUTOCSETAUTOHIDE:
+ case Message::AutoCSetAutoHide:
ac.autoHide = wParam != 0;
break;
- case SCI_AUTOCGETAUTOHIDE:
+ case Message::AutoCGetAutoHide:
return ac.autoHide;
- case SCI_AUTOCSETDROPRESTOFWORD:
+ case Message::AutoCSetDropRestOfWord:
ac.dropRestOfWord = wParam != 0;
break;
- case SCI_AUTOCGETDROPRESTOFWORD:
+ case Message::AutoCGetDropRestOfWord:
return ac.dropRestOfWord;
- case SCI_AUTOCSETMAXHEIGHT:
+ case Message::AutoCSetMaxHeight:
ac.lb->SetVisibleRows(static_cast<int>(wParam));
break;
- case SCI_AUTOCGETMAXHEIGHT:
+ case Message::AutoCGetMaxHeight:
return ac.lb->GetVisibleRows();
- case SCI_AUTOCSETMAXWIDTH:
+ case Message::AutoCSetMaxWidth:
maxListWidth = static_cast<int>(wParam);
break;
- case SCI_AUTOCGETMAXWIDTH:
+ case Message::AutoCGetMaxWidth:
return maxListWidth;
- case SCI_REGISTERIMAGE:
+ case Message::RegisterImage:
ac.lb->RegisterImage(static_cast<int>(wParam), ConstCharPtrFromSPtr(lParam));
break;
- case SCI_REGISTERRGBAIMAGE:
+ case Message::RegisterRGBAImage:
ac.lb->RegisterRGBAImage(static_cast<int>(wParam), static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y),
ConstUCharPtrFromSPtr(lParam));
break;
- case SCI_CLEARREGISTEREDIMAGES:
+ case Message::ClearRegisteredImages:
ac.lb->ClearRegisteredImages();
break;
- case SCI_AUTOCSETTYPESEPARATOR:
+ case Message::AutoCSetTypeSeparator:
ac.SetTypesep(static_cast<char>(wParam));
break;
- case SCI_AUTOCGETTYPESEPARATOR:
+ case Message::AutoCGetTypeSeparator:
return ac.GetTypesep();
- case SCI_CALLTIPSHOW:
+ case Message::CallTipShow:
CallTipShow(LocationFromPosition(wParam),
ConstCharPtrFromSPtr(lParam));
break;
- case SCI_CALLTIPCANCEL:
+ case Message::CallTipCancel:
ct.CallTipCancel();
break;
- case SCI_CALLTIPACTIVE:
+ case Message::CallTipActive:
return ct.inCallTipMode;
- case SCI_CALLTIPPOSSTART:
+ case Message::CallTipPosStart:
return ct.posStartCallTip;
- case SCI_CALLTIPSETPOSSTART:
+ case Message::CallTipSetPosStart:
ct.posStartCallTip = wParam;
break;
- case SCI_CALLTIPSETHLT:
+ case Message::CallTipSetHlt:
ct.SetHighlight(wParam, lParam);
break;
- case SCI_CALLTIPSETBACK:
+ case Message::CallTipSetBack:
ct.colourBG = ColourRGBA::FromRGB(static_cast<int>(wParam));
- vs.styles[STYLE_CALLTIP].back = ct.colourBG;
+ vs.styles[StyleCallTip].back = ct.colourBG;
InvalidateStyleRedraw();
break;
- case SCI_CALLTIPSETFORE:
+ case Message::CallTipSetFore:
ct.colourUnSel = ColourRGBA::FromRGB(static_cast<int>(wParam));
- vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel;
+ vs.styles[StyleCallTip].fore = ct.colourUnSel;
InvalidateStyleRedraw();
break;
- case SCI_CALLTIPSETFOREHLT:
+ case Message::CallTipSetForeHlt:
ct.colourSel = ColourRGBA::FromRGB(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_CALLTIPUSESTYLE:
+ case Message::CallTipUseStyle:
ct.SetTabSize(static_cast<int>(wParam));
InvalidateStyleRedraw();
break;
- case SCI_CALLTIPSETPOSITION:
+ case Message::CallTipSetPosition:
ct.SetPosition(wParam != 0);
InvalidateStyleRedraw();
break;
- case SCI_USEPOPUP:
- displayPopupMenu = static_cast<int>(wParam);
+ case Message::UsePopUp:
+ displayPopupMenu = static_cast<PopUp>(wParam);
break;
- case SCI_GETLEXER:
+ case Message::GetLexer:
return DocumentLexState()->GetIdentifier();
- case SCI_SETILEXER:
+ case Message::SetILexer:
DocumentLexState()->SetInstance(static_cast<ILexer5 *>(PtrFromSPtr(lParam)));
return 0;
- case SCI_COLOURISE:
+ case Message::Colourise:
if (DocumentLexState()->UseContainerLexing()) {
pdoc->ModifiedAt(static_cast<Sci::Position>(wParam));
NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam);
@@ -1051,29 +1054,29 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
Redraw();
break;
- case SCI_SETPROPERTY:
+ case Message::SetProperty:
DocumentLexState()->PropSet(ConstCharPtrFromUPtr(wParam),
ConstCharPtrFromSPtr(lParam));
break;
- case SCI_GETPROPERTY:
+ case Message::GetProperty:
return StringResult(lParam, DocumentLexState()->PropGet(ConstCharPtrFromUPtr(wParam)));
- case SCI_GETPROPERTYEXPANDED:
+ case Message::GetPropertyExpanded:
return DocumentLexState()->PropGetExpanded(ConstCharPtrFromUPtr(wParam),
CharPtrFromSPtr(lParam));
- case SCI_GETPROPERTYINT:
+ case Message::GetPropertyInt:
return DocumentLexState()->PropGetInt(ConstCharPtrFromUPtr(wParam), static_cast<int>(lParam));
- case SCI_SETKEYWORDS:
+ case Message::SetKeyWords:
DocumentLexState()->SetWordList(static_cast<int>(wParam), ConstCharPtrFromSPtr(lParam));
break;
- case SCI_GETLEXERLANGUAGE:
+ case Message::GetLexerLanguage:
return StringResult(lParam, DocumentLexState()->GetName());
- case SCI_PRIVATELEXERCALL:
+ case Message::PrivateLexerCall:
return reinterpret_cast<sptr_t>(
DocumentLexState()->PrivateCall(static_cast<int>(wParam), PtrFromSPtr(lParam)));
@@ -1082,64 +1085,64 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
return 8;
#endif
- case SCI_PROPERTYNAMES:
+ case Message::PropertyNames:
return StringResult(lParam, DocumentLexState()->PropertyNames());
- case SCI_PROPERTYTYPE:
- return DocumentLexState()->PropertyType(ConstCharPtrFromUPtr(wParam));
+ case Message::PropertyType:
+ return static_cast<sptr_t>(DocumentLexState()->PropertyType(ConstCharPtrFromUPtr(wParam)));
- case SCI_DESCRIBEPROPERTY:
+ case Message::DescribeProperty:
return StringResult(lParam,
DocumentLexState()->DescribeProperty(ConstCharPtrFromUPtr(wParam)));
- case SCI_DESCRIBEKEYWORDSETS:
+ case Message::DescribeKeyWordSets:
return StringResult(lParam, DocumentLexState()->DescribeWordListSets());
- case SCI_GETLINEENDTYPESSUPPORTED:
- return DocumentLexState()->LineEndTypesSupported();
+ case Message::GetLineEndTypesSupported:
+ return static_cast<sptr_t>(DocumentLexState()->LineEndTypesSupported());
- case SCI_ALLOCATESUBSTYLES:
+ case Message::AllocateSubStyles:
return DocumentLexState()->AllocateSubStyles(static_cast<int>(wParam), static_cast<int>(lParam));
- case SCI_GETSUBSTYLESSTART:
+ case Message::GetSubStylesStart:
return DocumentLexState()->SubStylesStart(static_cast<int>(wParam));
- case SCI_GETSUBSTYLESLENGTH:
+ case Message::GetSubStylesLength:
return DocumentLexState()->SubStylesLength(static_cast<int>(wParam));
- case SCI_GETSTYLEFROMSUBSTYLE:
+ case Message::GetStyleFromSubStyle:
return DocumentLexState()->StyleFromSubStyle(static_cast<int>(wParam));
- case SCI_GETPRIMARYSTYLEFROMSTYLE:
+ case Message::GetPrimaryStyleFromStyle:
return DocumentLexState()->PrimaryStyleFromStyle(static_cast<int>(wParam));
- case SCI_FREESUBSTYLES:
+ case Message::FreeSubStyles:
DocumentLexState()->FreeSubStyles();
break;
- case SCI_SETIDENTIFIERS:
+ case Message::SetIdentifiers:
DocumentLexState()->SetIdentifiers(static_cast<int>(wParam),
ConstCharPtrFromSPtr(lParam));
break;
- case SCI_DISTANCETOSECONDARYSTYLES:
+ case Message::DistanceToSecondaryStyles:
return DocumentLexState()->DistanceToSecondaryStyles();
- case SCI_GETSUBSTYLEBASES:
+ case Message::GetSubStyleBases:
return StringResult(lParam, DocumentLexState()->GetSubStyleBases());
- case SCI_GETNAMEDSTYLES:
+ case Message::GetNamedStyles:
return DocumentLexState()->NamedStyles();
- case SCI_NAMEOFSTYLE:
+ case Message::NameOfStyle:
return StringResult(lParam, DocumentLexState()->
NameOfStyle(static_cast<int>(wParam)));
- case SCI_TAGSOFSTYLE:
+ case Message::TagsOfStyle:
return StringResult(lParam, DocumentLexState()->
TagsOfStyle(static_cast<int>(wParam)));
- case SCI_DESCRIPTIONOFSTYLE:
+ case Message::DescriptionOfStyle:
return StringResult(lParam, DocumentLexState()->
DescriptionOfStyle(static_cast<int>(wParam)));
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index d62162196..47e24796d 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -8,7 +8,7 @@
#ifndef SCINTILLABASE_H
#define SCINTILLABASE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class LexState;
/**
@@ -29,15 +29,15 @@ protected:
idcmdSelectAll=16
};
- int displayPopupMenu;
+ Scintilla::PopUp displayPopupMenu;
Menu popup;
- AutoComplete ac;
+ Scintilla::Internal::AutoComplete ac;
CallTip ct;
int listType; ///< 0 is an autocomplete list
int maxListWidth; /// Maximum width of list, in average character widths
- int multiAutoCMode; /// Mode for autocompleting when multiple selections are present
+ Scintilla::MultiAutoComplete multiAutoCMode; /// Mode for autocompleting when multiple selections are present
LexState *DocumentLexState();
void Colourise(int start, int end);
@@ -52,10 +52,10 @@ protected:
void Initialise() override {}
void Finalise() override;
- void InsertCharacter(std::string_view sv, CharacterSource charSource) override;
+ void InsertCharacter(std::string_view sv, Scintilla::CharacterSource charSource) override;
void Command(int cmdId);
void CancelModes() override;
- int KeyCommand(unsigned int iMessage) override;
+ int KeyCommand(Scintilla::Message iMessage) override;
void AutoCompleteInsert(Sci::Position startPos, Sci::Position removeLen, const char *text, Sci::Position textLen);
void AutoCompleteStart(Sci::Position lenEntered, const char *list);
@@ -65,7 +65,7 @@ protected:
int AutoCompleteGetCurrentText(char *buffer) const;
void AutoCompleteCharacterAdded(char ch);
void AutoCompleteCharacterDeleted();
- void AutoCompleteCompleted(char ch, unsigned int completionMethod);
+ void AutoCompleteCompleted(char ch, Scintilla::CompletionMethods completionMethod);
void AutoCompleteMoveToCurrentWord();
void AutoCompleteSelection();
void ListNotify(ListBoxEvent *plbe) override;
@@ -78,8 +78,8 @@ protected:
bool ShouldDisplayPopup(Point ptInWindowCoordinates) const;
void ContextMenu(Point pt);
- void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override;
- void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override;
+ void ButtonDownWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers) override;
+ void RightButtonDownWithModifiers(Point pt, unsigned int curTime, Scintilla::KeyMod modifiers) override;
void NotifyStyleToNeeded(Sci::Position endStyleNeeded) override;
void NotifyLexerChanged(Document *doc, void *userData) override;
@@ -88,7 +88,7 @@ public:
~ScintillaBase() override;
// Public so scintilla_send_message can use it
- sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ Scintilla::sptr_t WndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) override;
};
}
diff --git a/src/Selection.cxx b/src/Selection.cxx
index 0675ceefe..9cf4e6f09 100644
--- a/src/Selection.cxx
+++ b/src/Selection.cxx
@@ -17,12 +17,10 @@
#include "Debugging.h"
-#include "Scintilla.h"
-
#include "Position.h"
#include "Selection.h"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length, bool moveForEqual) noexcept {
if (insertion) {
diff --git a/src/Selection.h b/src/Selection.h
index 5cd3e6ae8..7912d03e5 100644
--- a/src/Selection.h
+++ b/src/Selection.h
@@ -8,7 +8,7 @@
#ifndef SELECTION_H
#define SELECTION_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class SelectionPosition {
Sci::Position position;
diff --git a/src/SparseVector.h b/src/SparseVector.h
index b0cfe2ded..31636165a 100644
--- a/src/SparseVector.h
+++ b/src/SparseVector.h
@@ -8,7 +8,7 @@
#ifndef SPARSEVECTOR_H
#define SPARSEVECTOR_H
-namespace Scintilla {
+namespace Scintilla::Internal {
// SparseVector is similar to RunStyles but is more efficient for cases where values occur
// for one position instead of over a range of positions.
diff --git a/src/SplitVector.h b/src/SplitVector.h
index e805c50dc..dc63b4ab6 100644
--- a/src/SplitVector.h
+++ b/src/SplitVector.h
@@ -9,7 +9,7 @@
#ifndef SPLITVECTOR_H
#define SPLITVECTOR_H
-namespace Scintilla {
+namespace Scintilla::Internal {
template <typename T>
class SplitVector {
diff --git a/src/Style.cxx b/src/Style.cxx
index 5d926bf92..d71b62d97 100644
--- a/src/Style.cxx
+++ b/src/Style.cxx
@@ -11,14 +11,16 @@
#include <optional>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
#include "Style.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
bool FontSpecification::operator==(const FontSpecification &other) const noexcept {
return fontName == other.fontName &&
@@ -60,14 +62,14 @@ void FontMeasurements::ClearMeasurements() noexcept {
Style::Style() : FontSpecification() {
Clear(ColourRGBA(0, 0, 0), ColourRGBA(0xff, 0xff, 0xff),
- Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, nullptr, SC_CHARSET_DEFAULT,
- SC_WEIGHT_NORMAL, false, false, false, CaseForce::mixed, true, true, false);
+ Platform::DefaultFontSize() * FontSizeMultiplier, nullptr, CharacterSet::Default,
+ FontWeight::Normal, false, false, false, CaseForce::mixed, true, true, false);
}
Style::Style(const Style &source) noexcept : FontSpecification(), FontMeasurements() {
Clear(ColourRGBA(0, 0, 0), ColourRGBA(0xff, 0xff, 0xff),
- 0, nullptr, 0,
- SC_WEIGHT_NORMAL, false, false, false, CaseForce::mixed, true, true, false);
+ 0, nullptr, CharacterSet::Ansi,
+ FontWeight::Normal, false, false, false, CaseForce::mixed, true, true, false);
fore = source.fore;
back = source.back;
characterSet = source.characterSet;
@@ -89,8 +91,8 @@ Style &Style::operator=(const Style &source) noexcept {
if (this == &source)
return * this;
Clear(ColourRGBA(0, 0, 0), ColourRGBA(0xff, 0xff, 0xff),
- 0, nullptr, SC_CHARSET_DEFAULT,
- SC_WEIGHT_NORMAL, false, false, false, CaseForce::mixed, true, true, false);
+ 0, nullptr, CharacterSet::Default,
+ FontWeight::Normal, false, false, false, CaseForce::mixed, true, true, false);
fore = source.fore;
back = source.back;
characterSet = source.characterSet;
@@ -107,8 +109,8 @@ Style &Style::operator=(const Style &source) noexcept {
}
void Style::Clear(ColourRGBA fore_, ColourRGBA back_, int size_,
- const char *fontName_, int characterSet_,
- int weight_, bool italic_, bool eolFilled_,
+ const char *fontName_, CharacterSet characterSet_,
+ FontWeight weight_, bool italic_, bool eolFilled_,
bool underline_, CaseForce caseForce_,
bool visible_, bool changeable_, bool hotspot_) noexcept {
fore = fore_;
diff --git a/src/Style.h b/src/Style.h
index cee63aa9e..8153d156e 100644
--- a/src/Style.h
+++ b/src/Style.h
@@ -8,22 +8,22 @@
#ifndef STYLE_H
#define STYLE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
struct FontSpecification {
const char *fontName;
- int weight;
+ Scintilla::FontWeight weight;
bool italic;
int size;
- int characterSet;
- int extraFontFlag;
+ Scintilla::CharacterSet characterSet;
+ Scintilla::FontQuality extraFontFlag;
FontSpecification() noexcept :
fontName(nullptr),
- weight(SC_WEIGHT_NORMAL),
+ weight(Scintilla::FontWeight::Normal),
italic(false),
- size(10 * SC_FONT_SIZE_MULTIPLIER),
- characterSet(0),
- extraFontFlag(0) {
+ size(10 * Scintilla::FontSizeMultiplier),
+ characterSet(Scintilla::CharacterSet::Ansi),
+ extraFontFlag(Scintilla::FontQuality::QualityDefault) {
}
bool operator==(const FontSpecification &other) const noexcept;
bool operator<(const FontSpecification &other) const noexcept;
@@ -64,8 +64,8 @@ public:
Style &operator=(Style &&) = delete;
void Clear(ColourRGBA fore_, ColourRGBA back_,
int size_,
- const char *fontName_, int characterSet_,
- int weight_, bool italic_, bool eolFilled_,
+ const char *fontName_, Scintilla::CharacterSet characterSet_,
+ Scintilla::FontWeight weight_, bool italic_, bool eolFilled_,
bool underline_, CaseForce caseForce_,
bool visible_, bool changeable_, bool hotspot_) noexcept;
void ClearTo(const Style &source) noexcept;
diff --git a/src/UniConversion.cxx b/src/UniConversion.cxx
index 06de6b8cf..91aea6cde 100644
--- a/src/UniConversion.cxx
+++ b/src/UniConversion.cxx
@@ -13,9 +13,7 @@
#include "UniConversion.h"
-using namespace Scintilla;
-
-namespace Scintilla {
+namespace Scintilla::Internal {
size_t UTF8Length(std::wstring_view wsv) noexcept {
size_t len = 0;
diff --git a/src/UniConversion.h b/src/UniConversion.h
index 4568e2dea..73426beed 100644
--- a/src/UniConversion.h
+++ b/src/UniConversion.h
@@ -8,7 +8,7 @@
#ifndef UNICONVERSION_H
#define UNICONVERSION_H
-namespace Scintilla {
+namespace Scintilla::Internal {
constexpr int UTF8MaxBytes = 4;
diff --git a/src/UniqueString.cxx b/src/UniqueString.cxx
index 322599672..61c1e062c 100644
--- a/src/UniqueString.cxx
+++ b/src/UniqueString.cxx
@@ -12,7 +12,7 @@
#include "UniqueString.h"
-namespace Scintilla {
+namespace Scintilla::Internal {
/// Equivalent to strdup but produces a std::unique_ptr<const char[]> allocation to go
/// into collections.
diff --git a/src/UniqueString.h b/src/UniqueString.h
index f7f7ebbdc..83cb69e78 100644
--- a/src/UniqueString.h
+++ b/src/UniqueString.h
@@ -11,7 +11,7 @@
#ifndef UNIQUESTRING_H
#define UNIQUESTRING_H
-namespace Scintilla {
+namespace Scintilla::Internal {
constexpr bool IsNullOrEmpty(const char *text) noexcept {
return text == nullptr || *text == '\0';
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 675c7cedf..8340cd68f 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -19,11 +19,12 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
#include "Position.h"
#include "UniqueString.h"
#include "Indicator.h"
@@ -33,27 +34,28 @@
#include "ViewStyle.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
-MarginStyle::MarginStyle(int style_, int width_, int mask_) noexcept :
- style(style_), width(width_), mask(mask_), sensitive(false), cursor(SC_CURSORREVERSEARROW) {
+MarginStyle::MarginStyle(MarginType style_, int width_, int mask_) noexcept :
+ style(style_), width(width_), mask(mask_), sensitive(false), cursor(CursorShape::ReverseArrow) {
}
bool MarginStyle::ShowsFolding() const noexcept {
- return (mask & SC_MASK_FOLDERS) != 0;
+ return (mask & MaskFolders) != 0;
}
FontRealised::FontRealised() noexcept = default;
FontRealised::~FontRealised() = default;
-void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs, const char *localeName) {
+void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technology, const FontSpecification &fs, const char *localeName) {
PLATFORM_ASSERT(fs.fontName);
- sizeZoomed = fs.size + zoomLevel * SC_FONT_SIZE_MULTIPLIER;
- if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
- sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
+ sizeZoomed = fs.size + zoomLevel * FontSizeMultiplier;
+ if (sizeZoomed <= 2 * FontSizeMultiplier) // Hangs if sizeZoomed <= 1
+ sizeZoomed = 2 * FontSizeMultiplier;
const float deviceHeight = static_cast<float>(surface.DeviceHeightFont(sizeZoomed));
- const FontParameters fp(fs.fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, fs.weight,
+ const FontParameters fp(fs.fontName, deviceHeight / FontSizeMultiplier, fs.weight,
fs.italic, fs.extraFontFlag, technology, fs.characterSet, localeName);
font = Font::Allocate(fp);
@@ -64,13 +66,13 @@ void FontRealised::Realise(Surface &surface, int zoomLevel, int technology, cons
spaceWidth = surface.WidthText(font.get(), " ");
}
-ViewStyle::ViewStyle() : markers(MARKER_MAX + 1), indicators(INDICATOR_MAX + 1) {
+ViewStyle::ViewStyle() : markers(MarkerMax + 1), indicators(static_cast<size_t>(IndicatorNumbers::Max) + 1) {
Init();
}
// Copy constructor only called when printing copies the screen ViewStyle so it can be
// modified for printing styles.
-ViewStyle::ViewStyle(const ViewStyle &source) : markers(MARKER_MAX + 1), indicators(INDICATOR_MAX + 1) {
+ViewStyle::ViewStyle(const ViewStyle &source) : markers(MarkerMax + 1), indicators(static_cast<size_t>(IndicatorNumbers::Max) + 1) {
Init(source.styles.size());
styles = source.styles;
for (size_t sty=0; sty<source.styles.size(); sty++) {
@@ -160,11 +162,11 @@ void ViewStyle::CalculateMarginWidthAndMask() noexcept {
for (int markBit = 0; markBit < 32; markBit++) {
const int maskBit = 1U << markBit;
switch (markers[markBit].markType) {
- case SC_MARK_EMPTY:
+ case MarkerSymbol::Empty:
maskInLine &= ~maskBit;
break;
- case SC_MARK_BACKGROUND:
- case SC_MARK_UNDERLINE:
+ case MarkerSymbol::Background:
+ case MarkerSymbol::Underline:
maskInLine &= ~maskBit;
maskDrawInText |= maskDefinedMarkers & maskBit;
break;
@@ -183,11 +185,11 @@ void ViewStyle::Init(size_t stylesSize_) {
// There are no image markers by default, so no need for calling CalcLargestMarkerHeight()
largestMarkerHeight = 0;
- indicators[0] = Indicator(INDIC_SQUIGGLE, ColourRGBA(0, 0x7f, 0));
- indicators[1] = Indicator(INDIC_TT, ColourRGBA(0, 0, 0xff));
- indicators[2] = Indicator(INDIC_PLAIN, ColourRGBA(0xff, 0, 0));
+ indicators[0] = Indicator(IndicatorStyle::Squiggle, ColourRGBA(0, 0x7f, 0));
+ indicators[1] = Indicator(IndicatorStyle::TT, ColourRGBA(0, 0, 0xff));
+ indicators[2] = Indicator(IndicatorStyle::Plain, ColourRGBA(0xff, 0, 0));
- technology = SC_TECHNOLOGY_DEFAULT;
+ technology = Technology::Default;
indicatorsDynamic = false;
indicatorsSetFore = false;
lineHeight = 1;
@@ -199,27 +201,27 @@ void ViewStyle::Init(size_t stylesSize_) {
tabWidth = spaceWidth * 8;
// Default is for no selection foregrounds
- elementColours.erase(SC_ELEMENT_SELECTION_TEXT);
- elementColours.erase(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT);
- elementColours.erase(SC_ELEMENT_SELECTION_SECONDARY_TEXT);
- elementColours.erase(SC_ELEMENT_SELECTION_NO_FOCUS_TEXT);
+ elementColours.erase(Element::SelectionText);
+ elementColours.erase(Element::SelectionAdditionalText);
+ elementColours.erase(Element::SelectionSecondaryText);
+ elementColours.erase(Element::SelectionNoFocusText);
// Shades of grey for selection backgrounds
- elementBaseColours[SC_ELEMENT_SELECTION_BACK] = ColourRGBA(0xc0, 0xc0, 0xc0, 0xff);
- elementBaseColours[SC_ELEMENT_SELECTION_ADDITIONAL_BACK] = ColourRGBA(0xd7, 0xd7, 0xd7, 0xff);
- elementBaseColours[SC_ELEMENT_SELECTION_SECONDARY_BACK] = ColourRGBA(0xb0, 0xb0, 0xb0, 0xff);
- elementBaseColours[SC_ELEMENT_SELECTION_NO_FOCUS_BACK] = ColourRGBA(0x80, 0x80, 0x80, 0x3f);
+ elementBaseColours[Element::SelectionBack] = ColourRGBA(0xc0, 0xc0, 0xc0, 0xff);
+ elementBaseColours[Element::SelectionAdditionalBack] = ColourRGBA(0xd7, 0xd7, 0xd7, 0xff);
+ elementBaseColours[Element::SelectionSecondaryBack] = ColourRGBA(0xb0, 0xb0, 0xb0, 0xff);
+ elementBaseColours[Element::SelectionNoFocusBack] = ColourRGBA(0x80, 0x80, 0x80, 0x3f);
elementAllowsTranslucent.insert({
- SC_ELEMENT_SELECTION_TEXT,
- SC_ELEMENT_SELECTION_BACK,
- SC_ELEMENT_SELECTION_ADDITIONAL_TEXT,
- SC_ELEMENT_SELECTION_ADDITIONAL_BACK,
- SC_ELEMENT_SELECTION_SECONDARY_TEXT,
- SC_ELEMENT_SELECTION_SECONDARY_BACK,
- SC_ELEMENT_SELECTION_NO_FOCUS_TEXT,
- SC_ELEMENT_SELECTION_BACK,
- SC_ELEMENT_SELECTION_NO_FOCUS_BACK,
+ Element::SelectionText,
+ Element::SelectionBack,
+ Element::SelectionAdditionalText,
+ Element::SelectionAdditionalBack,
+ Element::SelectionSecondaryText,
+ Element::SelectionSecondaryBack,
+ Element::SelectionNoFocusText,
+ Element::SelectionBack,
+ Element::SelectionNoFocusBack,
});
- selection.layer = Layer::base;
+ selection.layer = Layer::Base;
selection.eolFilled = false;
foldmarginColour.reset();
@@ -229,74 +231,74 @@ void ViewStyle::Init(size_t stylesSize_) {
controlCharWidth = 0;
selbar = Platform::Chrome();
selbarlight = Platform::ChromeHighlight();
- styles[STYLE_LINENUMBER].fore = ColourRGBA(0, 0, 0);
- styles[STYLE_LINENUMBER].back = Platform::Chrome();
+ styles[StyleLineNumber].fore = ColourRGBA(0, 0, 0);
+ styles[StyleLineNumber].back = Platform::Chrome();
- elementBaseColours[SC_ELEMENT_CARET] = ColourRGBA(0, 0, 0);
- elementBaseColours[SC_ELEMENT_CARET_ADDITIONAL] = ColourRGBA(0x7f, 0x7f, 0x7f);
+ elementBaseColours[Element::Caret] = ColourRGBA(0, 0, 0);
+ elementBaseColours[Element::CaretAdditional] = ColourRGBA(0x7f, 0x7f, 0x7f);
elementAllowsTranslucent.insert({
- SC_ELEMENT_CARET,
- SC_ELEMENT_CARET_ADDITIONAL,
+ Element::Caret,
+ Element::CaretAdditional,
});
- caret.style = CARETSTYLE_LINE;
+ caret.style = CaretStyle::Line;
caret.width = 1;
- elementColours.erase(SC_ELEMENT_CARET_LINE_BACK);
- elementAllowsTranslucent.insert(SC_ELEMENT_CARET_LINE_BACK);
+ elementColours.erase(Element::CaretLineBack);
+ elementAllowsTranslucent.insert(Element::CaretLineBack);
caretLine.alwaysShow = false;
- caretLine.layer = Layer::base;
+ caretLine.layer = Layer::Base;
caretLine.frame = 0;
someStylesProtected = false;
someStylesForceCase = false;
hotspotUnderline = true;
- elementColours.erase(SC_ELEMENT_HOT_SPOT_ACTIVE);
- elementAllowsTranslucent.insert(SC_ELEMENT_HOT_SPOT_ACTIVE);
+ elementColours.erase(Element::HotSpotActive);
+ elementAllowsTranslucent.insert(Element::HotSpotActive);
leftMarginWidth = 1;
rightMarginWidth = 1;
- ms.resize(SC_MAX_MARGIN + 1);
- ms[0] = MarginStyle(SC_MARGIN_NUMBER);
- ms[1] = MarginStyle(SC_MARGIN_SYMBOL, 16, ~SC_MASK_FOLDERS);
- ms[2] = MarginStyle(SC_MARGIN_SYMBOL);
+ ms.resize(MaxMargin + 1);
+ ms[0] = MarginStyle(MarginType::Number);
+ ms[1] = MarginStyle(MarginType::Symbol, 16, ~MaskFolders);
+ ms[2] = MarginStyle(MarginType::Symbol);
marginInside = true;
CalculateMarginWidthAndMask();
textStart = marginInside ? fixedColumnWidth : leftMarginWidth;
zoomLevel = 0;
- viewWhitespace = WhiteSpace::invisible;
- tabDrawMode = TabDrawMode::longArrow;
+ viewWhitespace = WhiteSpace::Invisible;
+ tabDrawMode = TabDrawMode::LongArrow;
whitespaceSize = 1;
- elementColours.erase(SC_ELEMENT_WHITE_SPACE);
- elementAllowsTranslucent.insert(SC_ELEMENT_WHITE_SPACE);
+ elementColours.erase(Element::WhiteSpace);
+ elementAllowsTranslucent.insert(Element::WhiteSpace);
- viewIndentationGuides = IndentView::none;
+ viewIndentationGuides = IndentView::None;
viewEOL = false;
- extraFontFlag = 0;
+ extraFontFlag = FontQuality::QualityDefault;
extraAscent = 0;
extraDescent = 0;
marginStyleOffset = 0;
- annotationVisible = ANNOTATION_HIDDEN;
+ annotationVisible = AnnotationVisible::Hidden;
annotationStyleOffset = 0;
- eolAnnotationVisible = EOLANNOTATION_HIDDEN;
+ eolAnnotationVisible = EOLAnnotationVisible::Hidden;
eolAnnotationStyleOffset = 0;
braceHighlightIndicatorSet = false;
braceHighlightIndicator = 0;
braceBadLightIndicatorSet = false;
braceBadLightIndicator = 0;
- edgeState = EDGE_NONE;
+ edgeState = EdgeVisualStyle::None;
theEdge = EdgeProperties(0, ColourRGBA(0xc0, 0xc0, 0xc0));
marginNumberPadding = 3;
ctrlCharPadding = 3; // +3 For a blank on front and rounded edge each side
lastSegItalicsOffset = 2;
- wrap.state = WrapMode::none;
- wrap.visualFlags = 0;
- wrap.visualFlagsLocation = 0;
+ wrap.state = Wrap::None;
+ wrap.visualFlags = WrapVisualFlag::None;
+ wrap.visualFlagsLocation = WrapVisualLocation::Default;
wrap.visualStartIndent = 0;
- wrap.indentMode = SC_WRAPINDENT_FIXED;
+ wrap.indentMode = WrapIndentMode::Fixed;
localeName = localeNameDefault;
}
@@ -313,7 +315,7 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {
}
// Create a FontRealised object for each unique font in the styles.
- CreateAndAddFont(styles[STYLE_DEFAULT]);
+ CreateAndAddFont(styles[StyleDefault]);
for (const Style &style : styles) {
CreateAndAddFont(style);
}
@@ -353,14 +355,14 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {
someStylesForceCase = std::any_of(styles.cbegin(), styles.cend(),
[](const Style &style) noexcept { return style.caseForce != Style::CaseForce::mixed; });
- aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
- spaceWidth = styles[STYLE_DEFAULT].spaceWidth;
+ aveCharWidth = styles[StyleDefault].aveCharWidth;
+ spaceWidth = styles[StyleDefault].spaceWidth;
tabWidth = spaceWidth * tabInChars;
controlCharWidth = 0.0;
if (controlCharSymbol >= 32) {
const char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
- controlCharWidth = surface.WidthText(styles[STYLE_CONTROLCHAR].font.get(), cc);
+ controlCharWidth = surface.WidthText(styles[StyleControlChar].font.get(), cc);
}
CalculateMarginWidthAndMask();
@@ -376,7 +378,7 @@ int ViewStyle::AllocateExtendedStyles(int numberStyles) {
nextExtendedStyle += numberStyles;
EnsureStyle(nextExtendedStyle);
for (int i=startRange; i<nextExtendedStyle; i++) {
- styles[i].ClearTo(styles[STYLE_DEFAULT]);
+ styles[i].ClearTo(styles[StyleDefault]);
}
return startRange;
}
@@ -388,25 +390,25 @@ void ViewStyle::EnsureStyle(size_t index) {
}
void ViewStyle::ResetDefaultStyle() {
- styles[STYLE_DEFAULT].Clear(ColourRGBA(0,0,0),
+ styles[StyleDefault].Clear(ColourRGBA(0,0,0),
ColourRGBA(0xff,0xff,0xff),
- Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, fontNames.Save(Platform::DefaultFont()),
- SC_CHARSET_DEFAULT,
- SC_WEIGHT_NORMAL, false, false, false, Style::CaseForce::mixed, true, true, false);
+ Platform::DefaultFontSize() * FontSizeMultiplier, fontNames.Save(Platform::DefaultFont()),
+ CharacterSet::Default,
+ FontWeight::Normal, false, false, false, Style::CaseForce::mixed, true, true, false);
}
void ViewStyle::ClearStyles() {
// Reset all styles to be like the default style
for (size_t i=0; i<styles.size(); i++) {
- if (i != STYLE_DEFAULT) {
- styles[i].ClearTo(styles[STYLE_DEFAULT]);
+ if (i != StyleDefault) {
+ styles[i].ClearTo(styles[StyleDefault]);
}
}
- styles[STYLE_LINENUMBER].back = Platform::Chrome();
+ styles[StyleLineNumber].back = Platform::Chrome();
// Set call tip fore/back to match the values previously set for call tips
- styles[STYLE_CALLTIP].back = ColourRGBA(0xff, 0xff, 0xff);
- styles[STYLE_CALLTIP].fore = ColourRGBA(0x80, 0x80, 0x80);
+ styles[StyleCallTip].back = ColourRGBA(0xff, 0xff, 0xff);
+ styles[StyleCallTip].fore = ColourRGBA(0x80, 0x80, 0x80);
}
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
@@ -444,11 +446,11 @@ void ViewStyle::CalcLargestMarkerHeight() noexcept {
largestMarkerHeight = 0;
for (const LineMarker &marker : markers) {
switch (marker.markType) {
- case SC_MARK_PIXMAP:
+ case MarkerSymbol::Pixmap:
if (marker.pxpm && marker.pxpm->GetHeight() > largestMarkerHeight)
largestMarkerHeight = marker.pxpm->GetHeight();
break;
- case SC_MARK_RGBAIMAGE:
+ case MarkerSymbol::RgbaImage:
if (marker.image && marker.image->GetHeight() > largestMarkerHeight)
largestMarkerHeight = marker.image->GetHeight();
break;
@@ -464,27 +466,27 @@ int ViewStyle::GetFrameWidth() const noexcept {
bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const {
return caretLine.frame && (caretActive || caretLine.alwaysShow) &&
- ElementColour(SC_ELEMENT_CARET_LINE_BACK) &&
- (caretLine.layer == Layer::base) && lineContainsCaret;
+ ElementColour(Element::CaretLineBack) &&
+ (caretLine.layer == Layer::Base) && lineContainsCaret;
}
// See if something overrides the line background colour: Either if caret is on the line
// and background colour is set for that, or if a marker is defined that forces its background
// colour onto the line, or if a marker is defined but has no selection margin in which to
-// display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order
+// display itself (as long as it's not an MarkerSymbol::Empty marker). These are checked in order
// with the earlier taking precedence. When multiple markers cause background override,
// the colour for the highest numbered one is used.
std::optional<ColourRGBA> ViewStyle::Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const {
std::optional<ColourRGBA> background;
if (!caretLine.frame && (caretActive || caretLine.alwaysShow) &&
- (caretLine.layer == Layer::base) && lineContainsCaret) {
- background = ElementColour(SC_ELEMENT_CARET_LINE_BACK);
+ (caretLine.layer == Layer::Base) && lineContainsCaret) {
+ background = ElementColour(Element::CaretLineBack);
}
if (!background && marksOfLine) {
int marks = marksOfLine;
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
- if ((marks & 1) && (markers[markBit].markType == SC_MARK_BACKGROUND) &&
- (markers[markBit].layer == Layer::base)) {
+ if ((marks & 1) && (markers[markBit].markType == MarkerSymbol::Background) &&
+ (markers[markBit].layer == Layer::Base)) {
background = markers[markBit].back;
}
marks >>= 1;
@@ -495,7 +497,7 @@ std::optional<ColourRGBA> ViewStyle::Background(int marksOfLine, bool caretActiv
if (marksMasked) {
for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) {
if ((marksMasked & 1) &&
- (markers[markBit].layer == Layer::base)) {
+ (markers[markBit].layer == Layer::Base)) {
background = markers[markBit].back;
}
marksMasked >>= 1;
@@ -510,29 +512,29 @@ std::optional<ColourRGBA> ViewStyle::Background(int marksOfLine, bool caretActiv
}
bool ViewStyle::SelectionBackgroundDrawn() const noexcept {
- return selection.layer == Layer::base;
+ return selection.layer == Layer::Base;
}
bool ViewStyle::SelectionTextDrawn() const {
return
- ElementIsSet(SC_ELEMENT_SELECTION_TEXT) ||
- ElementIsSet(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT) ||
- ElementIsSet(SC_ELEMENT_SELECTION_SECONDARY_TEXT) ||
- ElementIsSet(SC_ELEMENT_SELECTION_NO_FOCUS_TEXT);
+ ElementIsSet(Element::SelectionText) ||
+ ElementIsSet(Element::SelectionAdditionalText) ||
+ ElementIsSet(Element::SelectionSecondaryText) ||
+ ElementIsSet(Element::SelectionNoFocusText);
}
bool ViewStyle::WhitespaceBackgroundDrawn() const {
- return (viewWhitespace != WhiteSpace::invisible) && (ElementIsSet(SC_ELEMENT_WHITE_SPACE_BACK));
+ return (viewWhitespace != WhiteSpace::Invisible) && (ElementIsSet(Element::WhiteSpaceBack));
}
bool ViewStyle::WhiteSpaceVisible(bool inIndent) const noexcept {
- return (!inIndent && viewWhitespace == WhiteSpace::visibleAfterIndent) ||
- (inIndent && viewWhitespace == WhiteSpace::visibleOnlyInIndent) ||
- viewWhitespace == WhiteSpace::visibleAlways;
+ return (!inIndent && viewWhitespace == WhiteSpace::VisibleAfterIndent) ||
+ (inIndent && viewWhitespace == WhiteSpace::VisibleOnlyInIndent) ||
+ viewWhitespace == WhiteSpace::VisibleAlways;
}
ColourRGBA ViewStyle::WrapColour() const {
- return ElementColour(SC_ELEMENT_WHITE_SPACE).value_or(styles[STYLE_DEFAULT].fore);
+ return ElementColour(Element::WhiteSpace).value_or(styles[StyleDefault].fore);
}
// Insert new edge in sorted order.
@@ -546,7 +548,7 @@ void ViewStyle::AddMultiEdge(uptr_t wParam, sptr_t lParam) {
EdgeProperties(column, lParam));
}
-std::optional<ColourRGBA> ViewStyle::ElementColour(int element) const {
+std::optional<ColourRGBA> ViewStyle::ElementColour(Element element) const {
ElementMap::const_iterator search = elementColours.find(element);
if (search != elementColours.end()) {
if (search->second.has_value()) {
@@ -562,18 +564,18 @@ std::optional<ColourRGBA> ViewStyle::ElementColour(int element) const {
return {};
}
-bool ViewStyle::ElementAllowsTranslucent(int element) const {
+bool ViewStyle::ElementAllowsTranslucent(Element element) const {
return elementAllowsTranslucent.count(element) > 0;
}
-bool ViewStyle::ResetElement(int element) {
+bool ViewStyle::ResetElement(Element element) {
ElementMap::const_iterator search = elementColours.find(element);
const bool changed = (search != elementColours.end()) && (search->second.has_value());
elementColours.erase(element);
return changed;
}
-bool ViewStyle::SetElementColour(int element, ColourRGBA colour) {
+bool ViewStyle::SetElementColour(Element element, ColourRGBA colour) {
ElementMap::const_iterator search = elementColours.find(element);
const bool changed =
(search == elementColours.end()) ||
@@ -582,7 +584,7 @@ bool ViewStyle::SetElementColour(int element, ColourRGBA colour) {
return changed;
}
-bool ViewStyle::SetElementColourOptional(int element, uptr_t wParam, sptr_t lParam) {
+bool ViewStyle::SetElementColourOptional(Element element, uptr_t wParam, sptr_t lParam) {
if (wParam) {
return SetElementColour(element, ColourRGBA::FromRGB(static_cast<int>(lParam)));
} else {
@@ -590,17 +592,17 @@ bool ViewStyle::SetElementColourOptional(int element, uptr_t wParam, sptr_t lPar
}
}
-void ViewStyle::SetElementRGB(int element, int rgb) {
+void ViewStyle::SetElementRGB(Element element, int rgb) {
const ColourRGBA current = ElementColour(element).value_or(ColourRGBA(0, 0, 0, 0));
elementColours[element] = ColourRGBA(ColourRGBA(rgb), current.GetAlpha());
}
-void ViewStyle::SetElementAlpha(int element, int alpha) {
+void ViewStyle::SetElementAlpha(Element element, int alpha) {
const ColourRGBA current = ElementColour(element).value_or(ColourRGBA(0, 0, 0, 0));
elementColours[element] = ColourRGBA(current, std::min(alpha, 0xff));
}
-bool ViewStyle::ElementIsSet(int element) const {
+bool ViewStyle::ElementIsSet(Element element) const {
ElementMap::const_iterator search = elementColours.find(element);
if (search != elementColours.end()) {
return search->second.has_value();
@@ -608,7 +610,7 @@ bool ViewStyle::ElementIsSet(int element) const {
return false;
}
-bool ViewStyle::SetElementBase(int element, ColourRGBA colour) {
+bool ViewStyle::SetElementBase(Element element, ColourRGBA colour) {
ElementMap::const_iterator search = elementBaseColours.find(element);
const bool changed =
(search == elementBaseColours.end()) ||
@@ -617,34 +619,19 @@ bool ViewStyle::SetElementBase(int element, ColourRGBA colour) {
return changed;
}
-bool ViewStyle::SetWrapState(int wrapState_) noexcept {
- WrapMode wrapStateWanted;
- switch (wrapState_) {
- case SC_WRAP_WORD:
- wrapStateWanted = WrapMode::word;
- break;
- case SC_WRAP_CHAR:
- wrapStateWanted = WrapMode::character;
- break;
- case SC_WRAP_WHITESPACE:
- wrapStateWanted = WrapMode::whitespace;
- break;
- default:
- wrapStateWanted = WrapMode::none;
- break;
- }
- const bool changed = wrap.state != wrapStateWanted;
- wrap.state = wrapStateWanted;
+bool ViewStyle::SetWrapState(Wrap wrapState_) noexcept {
+ const bool changed = wrap.state != wrapState_;
+ wrap.state = wrapState_;
return changed;
}
-bool ViewStyle::SetWrapVisualFlags(int wrapVisualFlags_) noexcept {
+bool ViewStyle::SetWrapVisualFlags(WrapVisualFlag wrapVisualFlags_) noexcept {
const bool changed = wrap.visualFlags != wrapVisualFlags_;
wrap.visualFlags = wrapVisualFlags_;
return changed;
}
-bool ViewStyle::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) noexcept {
+bool ViewStyle::SetWrapVisualFlagsLocation(WrapVisualLocation wrapVisualFlagsLocation_) noexcept {
const bool changed = wrap.visualFlagsLocation != wrapVisualFlagsLocation_;
wrap.visualFlagsLocation = wrapVisualFlagsLocation_;
return changed;
@@ -656,45 +643,45 @@ bool ViewStyle::SetWrapVisualStartIndent(int wrapVisualStartIndent_) noexcept {
return changed;
}
-bool ViewStyle::SetWrapIndentMode(int wrapIndentMode_) noexcept {
+bool ViewStyle::SetWrapIndentMode(WrapIndentMode wrapIndentMode_) noexcept {
const bool changed = wrap.indentMode != wrapIndentMode_;
wrap.indentMode = wrapIndentMode_;
return changed;
}
bool ViewStyle::IsBlockCaretStyle() const noexcept {
- return ((caret.style & CARETSTYLE_INS_MASK) == CARETSTYLE_BLOCK) ||
- (caret.style & CARETSTYLE_OVERSTRIKE_BLOCK) != 0;
+ return ((caret.style & CaretStyle::InsMask) == CaretStyle::Block) ||
+ (FlagSet(caret.style, CaretStyle::OverstrikeBlock)) != 0;
}
bool ViewStyle::IsCaretVisible() const noexcept {
- return caret.width > 0 && caret.style != CARETSTYLE_INVISIBLE;
+ return caret.width > 0 && caret.style != CaretStyle::Invisible;
}
bool ViewStyle::DrawCaretInsideSelection(bool inOverstrike, bool imeCaretBlockOverride) const noexcept {
- if (caret.style & CARETSTYLE_BLOCK_AFTER)
+ if (FlagSet(caret.style, CaretStyle::BlockAfter))
return false;
- return ((caret.style & CARETSTYLE_INS_MASK) == CARETSTYLE_BLOCK) ||
- (inOverstrike && (caret.style & CARETSTYLE_OVERSTRIKE_BLOCK) != 0) ||
+ return ((caret.style & CaretStyle::InsMask) == CaretStyle::Block) ||
+ (inOverstrike && (FlagSet(caret.style, CaretStyle::OverstrikeBlock)) != 0) ||
imeCaretBlockOverride;
}
ViewStyle::CaretShape ViewStyle::CaretShapeForMode(bool inOverstrike) const noexcept {
if (inOverstrike) {
- return (caret.style & CARETSTYLE_OVERSTRIKE_BLOCK) ? CaretShape::block : CaretShape::bar;
+ return (FlagSet(caret.style, CaretStyle::OverstrikeBlock)) ? CaretShape::block : CaretShape::bar;
}
- const int caretStyle = caret.style & CARETSTYLE_INS_MASK;
- return (caretStyle <= CARETSTYLE_BLOCK) ? static_cast<CaretShape>(caretStyle) : CaretShape::line;
+ const CaretStyle caretStyle = caret.style & CaretStyle::InsMask;
+ return (caretStyle <= CaretStyle::Block) ? static_cast<CaretShape>(caretStyle) : CaretShape::line;
}
void ViewStyle::AllocStyles(size_t sizeNew) {
size_t i=styles.size();
styles.resize(sizeNew);
- if (styles.size() > STYLE_DEFAULT) {
+ if (styles.size() > StyleDefault) {
for (; i<sizeNew; i++) {
- if (i != STYLE_DEFAULT) {
- styles[i].ClearTo(styles[STYLE_DEFAULT]);
+ if (i != StyleDefault) {
+ styles[i].ClearTo(styles[StyleDefault]);
}
}
}
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 798595ddc..b59f441b1 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -8,19 +8,19 @@
#ifndef VIEWSTYLE_H
#define VIEWSTYLE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
*/
class MarginStyle {
public:
- int style;
+ Scintilla::MarginType style;
ColourRGBA back;
int width;
int mask;
bool sensitive;
- int cursor;
- MarginStyle(int style_= SC_MARGIN_SYMBOL, int width_=0, int mask_=0) noexcept;
+ Scintilla::CursorShape cursor;
+ MarginStyle(Scintilla::MarginType style_= Scintilla::MarginType::Symbol, int width_=0, int mask_=0) noexcept;
bool ShowsFolding() const noexcept;
};
@@ -38,20 +38,12 @@ public:
FontRealised &operator=(const FontRealised &) = delete;
FontRealised &operator=(FontRealised &&) = delete;
virtual ~FontRealised();
- void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs, const char *localeName);
+ void Realise(Surface &surface, int zoomLevel, Scintilla::Technology technology, const FontSpecification &fs, const char *localeName);
};
-enum class IndentView {none, real, lookForward, lookBoth};
-
-enum class WhiteSpace {invisible=0, visibleAlways=1, visibleAfterIndent=2, visibleOnlyInIndent=3};
-
-enum class TabDrawMode {longArrow=0, strikeOut=1};
-
typedef std::map<FontSpecification, std::unique_ptr<FontRealised>> FontMap;
-enum class WrapMode { none, word, character, whitespace };
-
-inline std::optional<ColourRGBA> OptionalColour(uptr_t wParam, sptr_t lParam) {
+inline std::optional<ColourRGBA> OptionalColour(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) {
if (wParam) {
return ColourRGBA::FromRGB(static_cast<int>(lParam));
} else {
@@ -61,14 +53,14 @@ inline std::optional<ColourRGBA> OptionalColour(uptr_t wParam, sptr_t lParam) {
struct SelectionAppearance {
// Whether to draw on base layer or over text
- Layer layer;
+ Scintilla::Layer layer;
// Draw selection past line end characters up to right border
bool eolFilled;
};
struct CaretLineAppearance {
// Whether to draw on base layer or over text
- Layer layer;
+ Scintilla::Layer layer;
// Also show when non-focused
bool alwaysShow;
// Non-0: draw a rectangle around line instead of filling line. Value is pixel width of frame
@@ -77,22 +69,22 @@ struct CaretLineAppearance {
struct CaretAppearance {
// Line, block, over-strike bar ...
- int style;
+ Scintilla::CaretStyle style;
// Width in pixels
int width;
};
struct WrapAppearance {
// No wrapping, word, character, whitespace appearance
- WrapMode state;
+ Scintilla::Wrap state;
// Show indication of wrap at line end, line start, or in margin
- int visualFlags;
+ Scintilla::WrapVisualFlag visualFlags;
// Show indication near margin or near text
- int visualFlagsLocation;
+ Scintilla::WrapVisualLocation visualFlagsLocation;
// How much indentation to show wrapping
int visualStartIndent;
- // SC_WRAPINDENT_FIXED, _SAME, _INDENT, _DEEPINDENT
- int indentMode;
+ // WrapIndentMode::Fixed, _SAME, _INDENT, _DEEPINDENT
+ Scintilla::WrapIndentMode indentMode;
};
struct EdgeProperties {
@@ -101,11 +93,23 @@ struct EdgeProperties {
EdgeProperties(int column_ = 0, ColourRGBA colour_ = ColourRGBA::FromRGB(0)) noexcept :
column(column_), colour(colour_) {
}
- EdgeProperties(uptr_t wParam, sptr_t lParam) noexcept :
+ EdgeProperties(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) noexcept :
column(static_cast<int>(wParam)), colour(ColourRGBA::FromRGB(static_cast<int>(lParam))) {
}
};
+// This is an old style enum so that its members can be used directly as indices without casting
+enum StyleIndices {
+ StyleDefault = static_cast<int>(Scintilla::StylesCommon::Default),
+ StyleLineNumber = static_cast<int>(Scintilla::StylesCommon::LineNumber),
+ StyleBraceLight = static_cast<int>(Scintilla::StylesCommon::BraceLight),
+ StyleBraceBad = static_cast<int>(Scintilla::StylesCommon::BraceBad),
+ StyleControlChar = static_cast<int>(Scintilla::StylesCommon::ControlChar),
+ StyleIndentGuide = static_cast<int>(Scintilla::StylesCommon::IndentGuide),
+ StyleCallTip = static_cast<int>(Scintilla::StylesCommon::CallTip),
+ StyleFoldDisplayText = static_cast<int>(Scintilla::StylesCommon::FoldDisplayText),
+};
+
/**
*/
class ViewStyle {
@@ -119,7 +123,7 @@ public:
std::vector<Indicator> indicators;
bool indicatorsDynamic;
bool indicatorsSetFore;
- int technology;
+ Scintilla::Technology technology;
int lineHeight;
int lineOverlap;
unsigned int maxAscent;
@@ -147,10 +151,10 @@ public:
bool marginInside; ///< true: margin included in text view, false: separate views
int textStart; ///< Starting x position of text within the view
int zoomLevel;
- WhiteSpace viewWhitespace;
- TabDrawMode tabDrawMode;
+ Scintilla::WhiteSpace viewWhitespace;
+ Scintilla::TabDrawMode tabDrawMode;
int whitespaceSize;
- IndentView viewIndentationGuides;
+ Scintilla::IndentView viewIndentationGuides;
bool viewEOL;
CaretAppearance caret;
@@ -159,29 +163,29 @@ public:
bool someStylesProtected;
bool someStylesForceCase;
- int extraFontFlag;
+ Scintilla::FontQuality extraFontFlag;
int extraAscent;
int extraDescent;
int marginStyleOffset;
- int annotationVisible;
+ Scintilla::AnnotationVisible annotationVisible;
int annotationStyleOffset;
- int eolAnnotationVisible;
+ Scintilla::EOLAnnotationVisible eolAnnotationVisible;
int eolAnnotationStyleOffset;
bool braceHighlightIndicatorSet;
int braceHighlightIndicator;
bool braceBadLightIndicatorSet;
int braceBadLightIndicator;
- int edgeState;
+ Scintilla::EdgeVisualStyle edgeState;
EdgeProperties theEdge;
std::vector<EdgeProperties> theMultiEdge;
int marginNumberPadding; // the right-side padding of the number margin
int ctrlCharPadding; // the padding around control character text blobs
int lastSegItalicsOffset; // the offset so as not to clip italic characters at EOLs
- using ElementMap = std::map<int, std::optional<ColourRGBA>>;
+ using ElementMap = std::map<Scintilla::Element, std::optional<ColourRGBA>>;
ElementMap elementColours;
ElementMap elementBaseColours;
- std::set<int> elementAllowsTranslucent;
+ std::set<Scintilla::Element> elementAllowsTranslucent;
WrapAppearance wrap;
@@ -217,23 +221,23 @@ public:
bool WhitespaceBackgroundDrawn() const;
ColourRGBA WrapColour() const;
- void AddMultiEdge(uptr_t wParam, sptr_t lParam);
-
- std::optional<ColourRGBA> ElementColour(int element) const;
- bool ElementAllowsTranslucent(int element) const;
- bool ResetElement(int element);
- bool SetElementColour(int element, ColourRGBA colour);
- bool SetElementColourOptional(int element, uptr_t wParam, sptr_t lParam);
- void SetElementRGB(int element, int rgb);
- void SetElementAlpha(int element, int alpha);
- bool ElementIsSet(int element) const;
- bool SetElementBase(int element, ColourRGBA colour);
-
- bool SetWrapState(int wrapState_) noexcept;
- bool SetWrapVisualFlags(int wrapVisualFlags_) noexcept;
- bool SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation_) noexcept;
+ void AddMultiEdge(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
+
+ std::optional<ColourRGBA> ElementColour(Scintilla::Element element) const;
+ bool ElementAllowsTranslucent(Scintilla::Element element) const;
+ bool ResetElement(Scintilla::Element element);
+ bool SetElementColour(Scintilla::Element element, ColourRGBA colour);
+ bool SetElementColourOptional(Scintilla::Element element, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
+ void SetElementRGB(Scintilla::Element element, int rgb);
+ void SetElementAlpha(Scintilla::Element element, int alpha);
+ bool ElementIsSet(Scintilla::Element element) const;
+ bool SetElementBase(Scintilla::Element element, ColourRGBA colour);
+
+ bool SetWrapState(Scintilla::Wrap wrapState_) noexcept;
+ bool SetWrapVisualFlags(Scintilla::WrapVisualFlag wrapVisualFlags_) noexcept;
+ bool SetWrapVisualFlagsLocation(Scintilla::WrapVisualLocation wrapVisualFlagsLocation_) noexcept;
bool SetWrapVisualStartIndent(int wrapVisualStartIndent_) noexcept;
- bool SetWrapIndentMode(int wrapIndentMode_) noexcept;
+ bool SetWrapIndentMode(Scintilla::WrapIndentMode wrapIndentMode_) noexcept;
bool WhiteSpaceVisible(bool inIndent) const noexcept;
diff --git a/src/XPM.cxx b/src/XPM.cxx
index ca4804e5d..eba3fb6c2 100644
--- a/src/XPM.cxx
+++ b/src/XPM.cxx
@@ -17,6 +17,8 @@
#include <iterator>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
@@ -24,6 +26,7 @@
#include "XPM.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
namespace {
diff --git a/src/XPM.h b/src/XPM.h
index dc0468c1d..4ec020580 100644
--- a/src/XPM.h
+++ b/src/XPM.h
@@ -8,7 +8,7 @@
#ifndef XPM_H
#define XPM_H
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
* Hold a pixmap in XPM format.