aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-05-24 19:31:06 +1000
committerNeil <nyamatongwe@gmail.com>2021-05-24 19:31:06 +1000
commit92290868cf9753d2df0d494cb44e2ff62a570b58 (patch)
tree001e6cfce84372a03997de3138d630751ee8d38a
parentee1886079d0a5cd350ee8e3379be347943ba93ae (diff)
downloadscintilla-mirror-92290868cf9753d2df0d494cb44e2ff62a570b58.tar.gz
Define C++ version of the Scintilla API in ScintillaTypes.h, ScintillaMessages.h
and ScintillaStructures.h using scoped enumerations. Use these headers instead of Scintilla.h internally. External definitions go in the Scintilla namespace and internal definitio0ns in Scintilla::Internal.
-rw-r--r--cocoa/PlatCocoa.h22
-rw-r--r--cocoa/PlatCocoa.mm91
-rw-r--r--cocoa/QuartzTextStyle.h8
-rw-r--r--cocoa/QuartzTextStyleAttribute.h4
-rw-r--r--cocoa/ScintillaCocoa.h10
-rw-r--r--cocoa/ScintillaCocoa.mm431
-rw-r--r--cocoa/ScintillaView.mm127
-rw-r--r--doc/ScintillaDoc.html71
-rw-r--r--doc/ScintillaHistory.html4
-rwxr-xr-xgtk/PlatGTK.cxx90
-rwxr-xr-xgtk/ScintillaGTK.cxx173
-rwxr-xr-xgtk/ScintillaGTK.h12
-rw-r--r--gtk/ScintillaGTKAccessible.cxx175
-rw-r--r--gtk/ScintillaGTKAccessible.h18
-rw-r--r--gtk/deps.mak82
-rw-r--r--include/ILoader.h4
-rw-r--r--include/Scintilla.iface6
-rw-r--r--include/ScintillaMessages.h778
-rw-r--r--include/ScintillaStructures.h103
-rw-r--r--include/ScintillaTypes.h786
-rw-r--r--qt/ScintillaEdit/ScintillaDocument.cpp20
-rw-r--r--qt/ScintillaEdit/ScintillaDocument.h2
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp77
-rw-r--r--qt/ScintillaEditBase/PlatQt.h8
-rw-r--r--qt/ScintillaEditBase/ScintillaEditBase.cpp29
-rw-r--r--qt/ScintillaEditBase/ScintillaEditBase.h9
-rw-r--r--qt/ScintillaEditBase/ScintillaQt.cpp34
-rw-r--r--qt/ScintillaEditBase/ScintillaQt.h17
-rw-r--r--scripts/Face.py17
-rw-r--r--scripts/HeaderOrder.txt13
-rw-r--r--scripts/ScintillaAPIFacer.py107
-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
-rw-r--r--test/unit/UnitTester.cxx2
-rw-r--r--test/unit/testCellBuffer.cxx274
-rw-r--r--test/unit/testCharClassify.cxx2
-rw-r--r--test/unit/testContractionState.cxx2
-rw-r--r--test/unit/testDecoration.cxx2
-rw-r--r--test/unit/testPartitioning.cxx2
-rw-r--r--test/unit/testPerLine.cxx31
-rw-r--r--test/unit/testRunStyles.cxx4
-rw-r--r--test/unit/testSparseVector.cxx2
-rw-r--r--test/unit/testSplitVector.cxx2
-rw-r--r--test/unit/testUniConversion.cxx2
-rw-r--r--test/unit/unitTest.cxx2
-rw-r--r--win32/HanjaDic.cxx2
-rw-r--r--win32/HanjaDic.h2
-rw-r--r--win32/PlatWin.cxx118
-rw-r--r--win32/PlatWin.h2
-rw-r--r--win32/Scintilla.vcxproj3
-rw-r--r--win32/ScintillaDLL.cxx12
-rw-r--r--win32/ScintillaWin.cxx483
-rw-r--r--win32/ScintillaWin.h7
120 files changed, 6042 insertions, 4062 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index 29c908baa..bcd9d87b3 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -17,26 +17,28 @@
#include <Cocoa/Cocoa.h>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
#include "QuartzTextLayout.h"
-NSRect PRectangleToNSRect(const Scintilla::PRectangle &rc);
-Scintilla::PRectangle NSRectToPRectangle(NSRect &rc);
-CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet);
+NSRect PRectangleToNSRect(const Scintilla::Internal::PRectangle &rc);
+Scintilla::Internal::PRectangle NSRectToPRectangle(NSRect &rc);
+CFStringEncoding EncodingFromCharacterSet(bool unicode, Scintilla::CharacterSet characterSet);
@interface ScintillaContextMenu : NSMenu {
- Scintilla::ScintillaCocoa *owner;
+ Scintilla::Internal::ScintillaCocoa *owner;
}
- (void) handleCommand: (NSMenuItem *) sender;
-- (void) setOwner: (Scintilla::ScintillaCocoa *) newOwner;
+- (void) setOwner: (Scintilla::Internal::ScintillaCocoa *) newOwner;
@end
-namespace Scintilla {
+namespace Scintilla::Internal {
// A class to do the actual text rendering for us using Quartz 2D.
class SurfaceImpl : public Surface {
@@ -84,7 +86,7 @@ public:
void SetMode(SurfaceMode mode) override;
void Release() noexcept override;
- int Supports(int feature) noexcept override;
+ int SupportsFeature(Scintilla::Supports feature) noexcept override;
bool Initialised() override;
/** Returns a CGImageRef that represents the surface. Returns NULL if this is not possible. */
@@ -96,7 +98,7 @@ public:
int DeviceHeightFont(int points) override;
void LineDraw(Point start, Point end, Stroke stroke) override;
void PolyLine(const Point *pts, size_t npts, Stroke stroke) override;
- void Polygon(const Scintilla::Point *pts, size_t npts, FillStroke fillStroke) override;
+ void Polygon(const Scintilla::Internal::Point *pts, size_t npts, FillStroke fillStroke) override;
void RectangleDraw(PRectangle rc, FillStroke fillStroke) override;
void RectangleFrame(PRectangle rc, Stroke stroke) override;
void FillRectangle(PRectangle rc, Fill fill) override;
@@ -108,7 +110,7 @@ public:
void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override;
void Ellipse(PRectangle rc, FillStroke fillStroke) override;
void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) override;
- void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource) override;
+ void Copy(PRectangle rc, Scintilla::Internal::Point from, Surface &surfaceSource) override;
std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourRGBA fore,
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 1cb4f9f65..aaa8714c4 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -33,6 +33,10 @@
#import <Foundation/NSGeometry.h>
+#import "ScintillaTypes.h"
+#import "ScintillaMessages.h"
+#import "ScintillaStructures.h"
+
#import "Debugging.h"
#import "Geometry.h"
#import "Platform.h"
@@ -45,6 +49,7 @@
#import "PlatCocoa.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
extern sptr_t scintilla_send_message(void *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam);
@@ -53,7 +58,7 @@ extern sptr_t scintilla_send_message(void *sci, unsigned int iMessage, uptr_t wP
/**
* Converts a Point as used by Scintilla to a Quartz-style CGPoint.
*/
-inline CGPoint CGPointFromPoint(Scintilla::Point pt) {
+inline CGPoint CGPointFromPoint(Scintilla::Internal::Point pt) {
return CGPointMake(pt.x, pt.y);
}
@@ -340,12 +345,12 @@ void GetPositions(CTLineRef line, std::vector<CGFloat> &positions) {
positions.begin(), std::plus<CGFloat>());
}
-const int SupportsCocoa[] = {
- SC_SUPPORTS_LINE_DRAWS_FINAL,
- SC_SUPPORTS_PIXEL_DIVISIONS,
- SC_SUPPORTS_FRACTIONAL_STROKE_WIDTH,
- SC_SUPPORTS_TRANSLUCENT_STROKE,
- SC_SUPPORTS_PIXEL_MODIFICATION,
+const Supports SupportsCocoa[] = {
+ Supports::LineDrawsFinal,
+ Supports::PixelDivisions,
+ Supports::FractionalStrokeWidth,
+ Supports::TranslucentStroke,
+ Supports::PixelModification,
};
}
@@ -487,8 +492,8 @@ void SurfaceImpl::SetMode(SurfaceMode mode_) {
//--------------------------------------------------------------------------------------------------
-int SurfaceImpl::Supports(int feature) noexcept {
- for (const int f : SupportsCocoa) {
+int SurfaceImpl::SupportsFeature(Supports feature) noexcept {
+ for (const Supports f : SupportsCocoa) {
if (f == feature)
return 1;
}
@@ -651,7 +656,7 @@ void SurfaceImpl::PolyLine(const Point *pts, size_t npts, Stroke stroke) {
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::Polygon(const Scintilla::Point *pts, size_t npts, FillStroke fillStroke) {
+void SurfaceImpl::Polygon(const Scintilla::Internal::Point *pts, size_t npts, FillStroke fillStroke) {
std::vector<CGPoint> points;
std::transform(pts, pts + npts, std::back_inserter(points), CGPointFromPoint);
@@ -780,7 +785,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
}
void SurfaceImpl::RoundedRectangle(PRectangle rc, FillStroke fillStroke) {
- // This is only called from the margin marker drawing code for SC_MARK_ROUNDRECT
+ // This is only called from the margin marker drawing code for MarkerSymbol::RoundRect
// The Win32 version does
// ::RoundRect(hdc, rc.left + 1, rc.top, rc.right - 1, rc.bottom, 8, 8 );
// which is a rectangle with rounded corners each having a radius of 4 pixels.
@@ -888,7 +893,7 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz
CGContextDrawPath(gc, mode);
}
-void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) {
+void Scintilla::Internal::SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) {
if (gc) {
const XYPOSITION halfStroke = fillStroke.stroke.width / 2.0f;
// Set the Fill color to match
@@ -937,7 +942,7 @@ void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize
}
}
-void Scintilla::SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) {
+void Scintilla::Internal::SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) {
if (!gc) {
return;
}
@@ -1135,7 +1140,7 @@ void SurfaceImpl::CopyImageRectangle(SurfaceImpl *source, PRectangle srcRect, PR
CGImageRelease(image);
}
-void SurfaceImpl::Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource) {
+void SurfaceImpl::Copy(PRectangle rc, Scintilla::Internal::Point from, Surface &surfaceSource) {
// Maybe we have to make the Surface two contexts:
// a bitmap context which we do all the drawing on, and then a "real" context
// which we copy the output to when we call "Synchronize". Ugh! Gross and slow!
@@ -1196,7 +1201,7 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION y
//--------------------------------------------------------------------------------------------------
-CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) {
+CFStringEncoding EncodingFromCharacterSet(bool unicode, CharacterSet characterSet) {
if (unicode)
return kCFStringEncodingUTF8;
@@ -1204,47 +1209,47 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) {
enum { notSupported = kCFStringEncodingISOLatin1};
switch (characterSet) {
- case SC_CHARSET_ANSI:
+ case CharacterSet::Ansi:
return kCFStringEncodingISOLatin1;
- case SC_CHARSET_DEFAULT:
+ case CharacterSet::Default:
return kCFStringEncodingISOLatin1;
- case SC_CHARSET_BALTIC:
+ case CharacterSet::Baltic:
return kCFStringEncodingWindowsBalticRim;
- case SC_CHARSET_CHINESEBIG5:
+ case CharacterSet::ChineseBig5:
return kCFStringEncodingBig5;
- case SC_CHARSET_EASTEUROPE:
+ case CharacterSet::EastEurope:
return kCFStringEncodingWindowsLatin2;
- case SC_CHARSET_GB2312:
+ case CharacterSet::GB2312:
return kCFStringEncodingGB_18030_2000;
- case SC_CHARSET_GREEK:
+ case CharacterSet::Greek:
return kCFStringEncodingWindowsGreek;
- case SC_CHARSET_HANGUL:
+ case CharacterSet::Hangul:
return kCFStringEncodingEUC_KR;
- case SC_CHARSET_MAC:
+ case CharacterSet::Mac:
return kCFStringEncodingMacRoman;
- case SC_CHARSET_OEM:
+ case CharacterSet::Oem:
return kCFStringEncodingISOLatin1;
- case SC_CHARSET_RUSSIAN:
+ case CharacterSet::Russian:
return kCFStringEncodingKOI8_R;
- case SC_CHARSET_CYRILLIC:
+ case CharacterSet::Cyrillic:
return kCFStringEncodingWindowsCyrillic;
- case SC_CHARSET_SHIFTJIS:
+ case CharacterSet::ShiftJis:
return kCFStringEncodingShiftJIS;
- case SC_CHARSET_SYMBOL:
+ case CharacterSet::Symbol:
return kCFStringEncodingMacSymbol;
- case SC_CHARSET_TURKISH:
+ case CharacterSet::Turkish:
return kCFStringEncodingWindowsLatin5;
- case SC_CHARSET_JOHAB:
+ case CharacterSet::Johab:
return kCFStringEncodingWindowsKoreanJohab;
- case SC_CHARSET_HEBREW:
+ case CharacterSet::Hebrew:
return kCFStringEncodingWindowsHebrew;
- case SC_CHARSET_ARABIC:
+ case CharacterSet::Arabic:
return kCFStringEncodingWindowsArabic;
- case SC_CHARSET_VIETNAMESE:
+ case CharacterSet::Vietnamese:
return kCFStringEncodingWindowsVietnamese;
- case SC_CHARSET_THAI:
+ case CharacterSet::Thai:
return kCFStringEncodingISOLatinThai;
- case SC_CHARSET_8859_15:
+ case CharacterSet::Iso8859_15:
return kCFStringEncodingISOLatin1;
default:
return notSupported;
@@ -1507,7 +1512,7 @@ void SurfaceImpl::FlushCachedState() {
void SurfaceImpl::FlushDrawing() {
}
-std::unique_ptr<Surface> Surface::Allocate(int) {
+std::unique_ptr<Surface> Surface::Allocate(Technology) {
return std::make_unique<SurfaceImpl>();
}
@@ -1711,7 +1716,7 @@ static NSImage *ImageFromXPM(XPM *pxpm) {
const int width = pxpm->GetWidth();
const int height = pxpm->GetHeight();
PRectangle rcxpm(0, 0, width, height);
- std::unique_ptr<Surface> surfaceBase(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr<Surface> surfaceBase(Surface::Allocate(Technology::Default));
std::unique_ptr<Surface> surfaceXPM = surfaceBase->AllocatePixMap(width, height);
SurfaceImpl *surfaceIXPM = static_cast<SurfaceImpl *>(surfaceXPM.get());
CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height));
@@ -1911,7 +1916,7 @@ public:
// ListBox methods
void SetFont(const Font *font_) override;
- void Create(Window &parent, int ctrlID, Scintilla::Point pt, int lineHeight_, bool unicodeMode_, int technology_) override;
+ void Create(Window &parent, int ctrlID, Scintilla::Internal::Point pt, int lineHeight_, bool unicodeMode_, Technology technology_) override;
void SetAverageCharWidth(int width) override;
void SetVisibleRows(int rows) override;
int GetVisibleRows() const override;
@@ -1944,8 +1949,8 @@ public:
void SelectionChange() override;
};
-void ListBoxImpl::Create(Window & /*parent*/, int /*ctrlID*/, Scintilla::Point pt,
- int lineHeight_, bool unicodeMode_, int) {
+void ListBoxImpl::Create(Window & /*parent*/, int /*ctrlID*/, Scintilla::Internal::Point pt,
+ int lineHeight_, bool unicodeMode_, Technology) {
lineHeight = lineHeight_;
unicodeMode = unicodeMode_;
maxWidth = 2000;
@@ -2077,7 +2082,7 @@ void ListBoxImpl::Append(char *s, int type) {
int count = Length();
ld.Add(count, type, s);
- Scintilla::SurfaceImpl surface;
+ Scintilla::Internal::SurfaceImpl surface;
XYPOSITION width = surface.WidthText(font.get(), s);
if (width > maxItemWidth) {
maxItemWidth = width;
@@ -2252,7 +2257,7 @@ NSMenu
//--------------------------------------------------------------------------------------------------
-- (void) setOwner: (Scintilla::ScintillaCocoa *) newOwner {
+- (void) setOwner: (Scintilla::Internal::ScintillaCocoa *) newOwner {
owner = newOwner;
}
diff --git a/cocoa/QuartzTextStyle.h b/cocoa/QuartzTextStyle.h
index f8d50ebe9..b86bb8636 100644
--- a/cocoa/QuartzTextStyle.h
+++ b/cocoa/QuartzTextStyle.h
@@ -18,7 +18,7 @@ public:
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
- characterSet = 0;
+ characterSet = Scintilla::CharacterSet::Ansi;
}
QuartzTextStyle(const QuartzTextStyle *other) {
@@ -63,7 +63,7 @@ public:
return static_cast<float>(::CTFontGetLeading(fontRef));
}
- void setFontRef(CTFontRef inRef, int characterSet_) {
+ void setFontRef(CTFontRef inRef, Scintilla::CharacterSet characterSet_) {
fontRef = inRef;
characterSet = characterSet_;
@@ -81,14 +81,14 @@ public:
return fontRef;
}
- int getCharacterSet() const noexcept {
+ Scintilla::CharacterSet getCharacterSet() const noexcept {
return characterSet;
}
private:
CFMutableDictionaryRef styleDict;
CTFontRef fontRef;
- int characterSet;
+ Scintilla::CharacterSet characterSet;
};
#endif
diff --git a/cocoa/QuartzTextStyleAttribute.h b/cocoa/QuartzTextStyleAttribute.h
index a71049036..d9c0e5a15 100644
--- a/cocoa/QuartzTextStyleAttribute.h
+++ b/cocoa/QuartzTextStyleAttribute.h
@@ -15,12 +15,12 @@
class QuartzFont {
public:
/** Create a font style from a name. */
- QuartzFont(const char *name, size_t length, float size, int weight, bool italic) {
+ QuartzFont(const char *name, size_t length, float size, Scintilla::FontWeight weight, bool italic) {
assert(name != NULL && length > 0 && name[length] == '\0');
CFStringRef fontName = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingMacRoman);
assert(fontName != NULL);
- bool bold = weight > SC_WEIGHT_NORMAL;
+ bool bold = weight > Scintilla::FontWeight::Normal;
if (bold || italic) {
CTFontSymbolicTraits desiredTrait = 0;
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h
index f99c39770..40c389f5f 100644
--- a/cocoa/ScintillaCocoa.h
+++ b/cocoa/ScintillaCocoa.h
@@ -80,7 +80,7 @@ extern "C" NSString *ScintillaRecPboardType;
- (void) idleTriggered: (NSNotification *) notification;
@end
-namespace Scintilla {
+namespace Scintilla::Internal {
/**
* Main scintilla class, implemented for OS X (Cocoa).
@@ -137,7 +137,7 @@ public:
void SetDelegate(id<ScintillaNotificationProtocol> delegate_);
void RegisterNotifyCallback(intptr_t windowid, SciNotifyFunc callback);
- sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t WndProc(Scintilla::Message iMessage, uptr_t wParam, sptr_t lParam) override;
NSScrollView *ScrollContainer() const;
SCIContentView *ContentView();
@@ -146,7 +146,7 @@ public:
bool Draw(NSRect rect, CGContextRef gc);
void PaintMargin(NSRect aRect);
- sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t DefWndProc(Scintilla::Message iMessage, uptr_t wParam, sptr_t lParam) override;
void TickFor(TickReason reason) override;
bool FineTickerRunning(TickReason reason) override;
void FineTickerStart(TickReason reason, int millis, int tolerance) override;
@@ -166,7 +166,7 @@ public:
// Notifications for the owner.
void NotifyChange() override;
void NotifyFocus(bool focus) override;
- void NotifyParent(SCNotification scn) override;
+ void NotifyParent(Scintilla::NotificationData scn) override;
void NotifyURIDropped(const char *uri);
bool HasSelection();
@@ -198,7 +198,7 @@ public:
void ObserverRemove();
void IdleWork() override;
void QueueIdleWork(WorkItems items, Sci::Position upTo) override;
- ptrdiff_t InsertText(NSString *input, CharacterSource charSource);
+ ptrdiff_t InsertText(NSString *input, Scintilla::CharacterSource charSource);
NSRange PositionsFromCharacters(NSRange rangeCharacters) const;
NSRange CharactersFromPositions(NSRange rangePositions) const;
NSString *RangeTextAsString(NSRange rangePositions) const;
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index fab06f3e6..6baba72d9 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -27,6 +27,10 @@
#import <QuartzCore/CAAnimation.h>
#import <QuartzCore/CATransaction.h>
+#import "ScintillaTypes.h"
+#import "ScintillaMessages.h"
+#import "ScintillaStructures.h"
+
#import "Debugging.h"
#import "Geometry.h"
#import "Platform.h"
@@ -35,6 +39,7 @@
#import "PlatCocoa.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
NSString *ScintillaRecPboardType = @"com.scintilla.utf16-plain-text.rectangular";
@@ -45,99 +50,107 @@ NSString *ScintillaRecPboardType = @"com.scintilla.utf16-plain-text.rectangular"
#define SCI_SCMD ( SCI_CMD | SCI_SHIFT)
#define SCI_SMETA ( SCI_META | SCI_SHIFT)
+namespace {
+
+constexpr Keys Key(char ch) {
+ return static_cast<Keys>(ch);
+}
+
+}
+
static const KeyToCommand macMapDefault[] = {
// OS X specific
- {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},
// Similar to Windows and GTK+
// Where equivalent clashes with OS X standard, use Meta instead
- {SCK_DOWN, SCI_NORM, SCI_LINEDOWN},
- {SCK_DOWN, SCI_SHIFT, SCI_LINEDOWNEXTEND},
- {SCK_DOWN, SCI_META, SCI_LINESCROLLDOWN},
- {SCK_DOWN, SCI_ASHIFT, SCI_LINEDOWNRECTEXTEND},
- {SCK_UP, SCI_NORM, SCI_LINEUP},
- {SCK_UP, SCI_SHIFT, SCI_LINEUPEXTEND},
- {SCK_UP, SCI_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_ALT, SCI_WORDLEFT},
- {SCK_LEFT, SCI_META, SCI_WORDLEFT},
- {SCK_LEFT, SCI_SMETA, SCI_WORDLEFTEXTEND},
- {SCK_LEFT, SCI_ASHIFT, SCI_CHARLEFTRECTEXTEND},
- {SCK_RIGHT, SCI_NORM, SCI_CHARRIGHT},
- {SCK_RIGHT, SCI_SHIFT, SCI_CHARRIGHTEXTEND},
- {SCK_RIGHT, SCI_ALT, SCI_WORDRIGHT},
- {SCK_RIGHT, SCI_META, SCI_WORDRIGHT},
- {SCK_RIGHT, SCI_SMETA, 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_DELWORDLEFT},
- {SCK_BACK, SCI_CSHIFT, SCI_DELLINELEFT},
- {'z', SCI_CMD, SCI_UNDO},
- {'z', SCI_SCMD, SCI_REDO},
- {'x', SCI_CMD, SCI_CUT},
- {'c', SCI_CMD, SCI_COPY},
- {'v', SCI_CMD, SCI_PASTE},
- {'a', SCI_CMD, 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_CMD, SCI_ZOOMIN},
- {SCK_SUBTRACT, SCI_CMD, SCI_ZOOMOUT},
- {SCK_DIVIDE, SCI_CMD, SCI_SETZOOM},
- {'l', SCI_CMD, 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},
+ {Keys::Down, SCI_NORM, Message::LineDown},
+ {Keys::Down, SCI_SHIFT, Message::LineDownExtend},
+ {Keys::Down, SCI_META, Message::LineScrollDown},
+ {Keys::Down, SCI_ASHIFT, Message::LineDownRectExtend},
+ {Keys::Up, SCI_NORM, Message::LineUp},
+ {Keys::Up, SCI_SHIFT, Message::LineUpExtend},
+ {Keys::Up, SCI_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_ALT, Message::WordLeft},
+ {Keys::Left, SCI_META, Message::WordLeft},
+ {Keys::Left, SCI_SMETA, Message::WordLeftExtend},
+ {Keys::Left, SCI_ASHIFT, Message::CharLeftRectExtend},
+ {Keys::Right, SCI_NORM, Message::CharRight},
+ {Keys::Right, SCI_SHIFT, Message::CharRightExtend},
+ {Keys::Right, SCI_ALT, Message::WordRight},
+ {Keys::Right, SCI_META, Message::WordRight},
+ {Keys::Right, SCI_SMETA, 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::DelWordLeft},
+ {Keys::Back, SCI_CSHIFT, Message::DelLineLeft},
+ {Key('z'), SCI_CMD, Message::Undo},
+ {Key('z'), SCI_SCMD, Message::Redo},
+ {Key('x'), SCI_CMD, Message::Cut},
+ {Key('c'), SCI_CMD, Message::Copy},
+ {Key('v'), SCI_CMD, Message::Paste},
+ {Key('a'), SCI_CMD, 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_CMD, Message::ZoomIn},
+ {Keys::Subtract, SCI_CMD, Message::ZoomOut},
+ {Keys::Divide, SCI_CMD, Message::SetZoom},
+ {Key('l'), SCI_CMD, 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), KeyMod::Norm, static_cast<Message>(0)},
};
//--------------------------------------------------------------------------------------------------
@@ -300,7 +313,7 @@ const CGFloat paddingHighlightY = 2;
- (void) hideMatch {
self.sFind = @"";
- self.positionFind = INVALID_POSITION;
+ self.positionFind = Sci::invalidPosition;
self.hidden = YES;
}
@@ -409,7 +422,7 @@ ScintillaCocoa::ScintillaCocoa(ScintillaView *sciView_, SCIContentView *viewCont
scrollTicks = 2000;
observer = NULL;
layerFindIndicator = NULL;
- imeInteraction = IMEInteraction::internal;
+ imeInteraction = IMEInteraction::Inline;
std::fill(timers, std::end(timers), nil);
Init();
}
@@ -428,13 +441,13 @@ ScintillaCocoa::~ScintillaCocoa() {
void ScintillaCocoa::Init() {
// Tell Scintilla not to buffer: Quartz buffers drawing for us.
- WndProc(SCI_SETBUFFEREDDRAW, 0, 0);
+ WndProc(Message::SetBufferedDraw, 0, 0);
// We are working with Unicode exclusively.
- WndProc(SCI_SETCODEPAGE, SC_CP_UTF8, 0);
+ WndProc(Message::SetCodePage, SC_CP_UTF8, 0);
// Add Mac specific key bindings.
- for (int i = 0; macMapDefault[i].key; i++)
+ for (int i = 0; static_cast<int>(macMapDefault[i].key); i++)
kmap.AssignCmdKey(macMapDefault[i].key, macMapDefault[i].modifiers, macMapDefault[i].msg);
}
@@ -590,7 +603,7 @@ std::unique_ptr<CaseFolder> ScintillaCocoa::CaseFolderForEncoding() {
return std::make_unique<CaseFolderUnicode>();
} else {
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
if (pdoc->dbcsCodePage == 0) {
std::unique_ptr<CaseFolderTable> pcf = std::make_unique<CaseFolderTable>();
pcf->StandardASCII();
@@ -639,7 +652,7 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, CaseMapping case
}
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
CFStringRef cfsVal = CFStringFromString(s.c_str(), s.length(), encoding);
if (!cfsVal) {
@@ -698,7 +711,7 @@ SCIContentView *ScintillaCocoa::ContentView() {
/**
* Return the top left visible point relative to the origin point of the whole document.
*/
-Scintilla::Point ScintillaCocoa::GetVisibleOriginInMain() const {
+Scintilla::Internal::Point ScintillaCocoa::GetVisibleOriginInMain() const {
NSScrollView *scrollView = ScrollContainer();
NSRect contentRect = scrollView.contentView.bounds;
return Point(static_cast<XYPOSITION>(contentRect.origin.x), static_cast<XYPOSITION>(contentRect.origin.y));
@@ -743,10 +756,10 @@ PRectangle ScintillaCocoa::GetClientDrawingRectangle() {
* a native Point structure. Base coordinates are used for the top window used in the view hierarchy.
* Returned value is in view coordinates.
*/
-Scintilla::Point ScintillaCocoa::ConvertPoint(NSPoint point) {
+Scintilla::Internal::Point ScintillaCocoa::ConvertPoint(NSPoint point) {
NSView *container = ContentView();
NSPoint result = [container convertPoint: point fromView: nil];
- Scintilla::Point ptOrigin = GetVisibleOriginInMain();
+ Scintilla::Internal::Point ptOrigin = GetVisibleOriginInMain();
return Point(static_cast<XYPOSITION>(result.x - ptOrigin.x), static_cast<XYPOSITION>(result.y - ptOrigin.y));
}
@@ -798,7 +811,7 @@ void ScintillaCocoa::Redraw() {
*/
sptr_t ScintillaCocoa::DirectFunction(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
sptr_t lParam) {
- return reinterpret_cast<ScintillaCocoa *>(ptr)->WndProc(iMessage, wParam, lParam);
+ return reinterpret_cast<ScintillaCocoa *>(ptr)->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
//--------------------------------------------------------------------------------------------------
@@ -837,66 +850,66 @@ bool SupportAnimatedFind() {
* would be system messages on Windows (e.g. for key down, mouse move etc.) are handled by
* directly calling appropriate handlers.
*/
-sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+sptr_t ScintillaCocoa::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
try {
switch (iMessage) {
- case SCI_GETDIRECTFUNCTION:
+ case Message::GetDirectFunction:
return reinterpret_cast<sptr_t>(DirectFunction);
- case SCI_GETDIRECTPOINTER:
+ case Message::GetDirectPointer:
return reinterpret_cast<sptr_t>(this);
- case SCI_SETBIDIRECTIONAL:
- bidirectional = static_cast<EditModel::Bidirectional>(wParam);
+ case Message::SetBidirectional:
+ bidirectional = static_cast<Bidirectional>(wParam);
// Invalidate all cached information including layout.
DropGraphics();
InvalidateStyleRedraw();
return 0;
- case SCI_TARGETASUTF8:
+ case Message::TargetAsUTF8:
return TargetAsUTF8(CharPtrFromSPtr(lParam));
- case SCI_ENCODEDFROMUTF8:
+ case Message::EncodedFromUTF8:
return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam),
CharPtrFromSPtr(lParam));
- case SCI_SETIMEINTERACTION:
+ case Message::SetIMEInteraction:
// Only inline IME supported on Cocoa
break;
- case SCI_GRABFOCUS:
+ case Message::GrabFocus:
[ContentView().window makeFirstResponder: ContentView()];
break;
- case SCI_SETBUFFEREDDRAW:
+ case Message::SetBufferedDraw:
// Buffered drawing not supported on Cocoa
view.bufferedDraw = false;
break;
- case SCI_FINDINDICATORSHOW:
+ case Message::FindIndicatorShow:
if (SupportAnimatedFind()) {
ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), YES);
}
return 0;
- case SCI_FINDINDICATORFLASH:
+ case Message::FindIndicatorFlash:
if (SupportAnimatedFind()) {
ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), NO);
}
return 0;
- case SCI_FINDINDICATORHIDE:
+ case Message::FindIndicatorHide:
HideFindIndicator();
return 0;
- case SCI_SETPHASESDRAW: {
+ case Message::SetPhasesDraw: {
sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam);
[sciView updateIndicatorIME];
return r;
}
- case SCI_GETACCESSIBILITY:
- return SC_ACCESSIBILITY_ENABLED;
+ case Message::GetAccessibility:
+ return static_cast<sptr_t>(Accessibility::Enabled);
default:
sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam);
@@ -904,9 +917,9 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar
return r;
}
} catch (std::bad_alloc &) {
- errorStatus = SC_STATUS_BADALLOC;
+ errorStatus = Status::BadAlloc;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return 0;
}
@@ -917,7 +930,7 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar
* In Windows lingo this is the handler which handles anything that wasn't handled in the normal
* window proc which would usually send the message back to generic window proc that Windows uses.
*/
-sptr_t ScintillaCocoa::DefWndProc(unsigned int, uptr_t, sptr_t) {
+sptr_t ScintillaCocoa::DefWndProc(Message, uptr_t, sptr_t) {
return 0;
}
@@ -1058,7 +1071,7 @@ void ScintillaCocoa::Paste(bool forceRectangular) {
void ScintillaCocoa::CTPaint(void *gc, NSRect rc) {
#pragma unused(rc)
- std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(Technology::Default));
surfaceWindow->Init(gc, wMain.GetID());
surfaceWindow->SetMode(SurfaceMode(ct.codePage, BidirectionalR2L()));
ct.PaintCT(surfaceWindow.get());
@@ -1200,7 +1213,7 @@ std::string ScintillaCocoa::UTF8FromEncoded(std::string_view encoded) const {
return std::string(encoded);
} else {
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
CFStringRef cfsVal = CFStringFromString(encoded.data(), encoded.length(), encoding);
std::string utf = EncodedBytesString(cfsVal, kCFStringEncodingUTF8);
if (cfsVal)
@@ -1216,7 +1229,7 @@ std::string ScintillaCocoa::EncodedFromUTF8(std::string_view utf8) const {
return std::string(utf8);
} else {
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
CFStringRef cfsVal = CFStringFromString(utf8.data(), utf8.length(), kCFStringEncodingUTF8);
const std::string sEncoded = EncodedBytesString(cfsVal, encoding);
if (cfsVal)
@@ -1347,17 +1360,17 @@ void ScintillaCocoa::StartDrag() {
Sci::Position ep;
PRectangle rcSel;
- if (startLine==endLine && WndProc(SCI_GETWRAPMODE, 0, 0) != SC_WRAP_NONE) {
+ if (startLine==endLine && WndProc(Message::GetWrapMode, 0, 0) != static_cast<sptr_t>(Wrap::None)) {
// Komodo bug http://bugs.activestate.com/show_bug.cgi?id=87571
// Scintilla bug https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3040200&group_id=2439
// If the width on a wrapped-line selection is negative,
// find a better bounding rectangle.
Point ptStart, ptEnd;
- startPos = WndProc(SCI_GETLINESELSTARTPOSITION, startLine, 0);
- endPos = WndProc(SCI_GETLINESELENDPOSITION, startLine, 0);
+ startPos = WndProc(Message::GetLineSelStartPosition, startLine, 0);
+ endPos = WndProc(Message::GetLineSelEndPosition, startLine, 0);
// step back a position if we're counting the newline
- ep = WndProc(SCI_GETLINEENDPOSITION, startLine, 0);
+ ep = WndProc(Message::GetLineEndPosition, startLine, 0);
if (endPos > ep) endPos = ep;
ptStart = LocationFromPosition(startPos);
ptEnd = LocationFromPosition(endPos);
@@ -1367,7 +1380,7 @@ void ScintillaCocoa::StartDrag() {
rcSel.right = ptEnd.x < client.right ? ptEnd.x : client.right;
} else {
// Find the bounding box.
- startPos = WndProc(SCI_POSITIONFROMLINE, startLine, 0);
+ startPos = WndProc(Message::PositionFromLine, startLine, 0);
rcSel.left = LocationFromPosition(startPos).x;
rcSel.right = client.right;
}
@@ -1379,11 +1392,11 @@ void ScintillaCocoa::StartDrag() {
} else {
rcSel.top = rcSel.bottom = rcSel.right = rcSel.left = -1;
for (Sci::Line l = startLine; l <= endLine; l++) {
- startPos = WndProc(SCI_GETLINESELSTARTPOSITION, l, 0);
- endPos = WndProc(SCI_GETLINESELENDPOSITION, l, 0);
+ startPos = WndProc(Message::GetLineSelStartPosition, l, 0);
+ endPos = WndProc(Message::GetLineSelEndPosition, l, 0);
if (endPos == startPos) continue;
// step back a position if we're counting the newline
- ep = WndProc(SCI_GETLINEENDPOSITION, l, 0);
+ ep = WndProc(Message::GetLineEndPosition, l, 0);
if (endPos > ep) endPos = ep;
pt = LocationFromPosition(startPos); // top left of line selection
if (pt.x < rcSel.left || rcSel.left < 0) rcSel.left = pt.x;
@@ -1601,7 +1614,7 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard *board, SelectionText *selec
if (data != nil) {
if (selectedText != nil) {
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
CFRange rangeAll = {0, static_cast<CFIndex>(data.length)};
CFIndex usedLen = 0;
CFStringGetBytes((CFStringRef)data, rangeAll, encoding, '?',
@@ -1617,7 +1630,7 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard *board, SelectionText *selec
std::string dest(reinterpret_cast<const char *>(buffer.data()), usedLen);
selectedText->Copy(dest, pdoc->dbcsCodePage,
- vs.styles[STYLE_DEFAULT].characterSet, rectangular, false);
+ vs.styles[StyleDefault].characterSet, rectangular, false);
}
return true;
}
@@ -1637,7 +1650,7 @@ Sci::Position ScintillaCocoa::TargetAsUTF8(char *text) const {
} else {
// Need to convert
const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
const std::string s = RangeText(targetRange.start.Position(), targetRange.end.Position());
CFStringRef cfsVal = CFStringFromString(s.c_str(), s.length(), encoding);
if (!cfsVal) {
@@ -1665,7 +1678,7 @@ NSString *ScintillaCocoa::RangeTextAsString(NSRange rangePositions) const {
} else {
// Need to convert
const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
CFStringRef cfsVal = CFStringFromString(text.c_str(), text.length(), encoding);
return (__bridge NSString *)cfsVal;
@@ -1741,7 +1754,7 @@ Sci::Position ScintillaCocoa::EncodedFromUTF8(const char *utf8, char *encoded) c
} else {
// Need to convert
const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
CFStringRef cfsVal = CFStringFromString(utf8, inputLength, kCFStringEncodingUTF8);
const std::string sEncoded = EncodedBytesString(cfsVal, encoding);
@@ -1774,14 +1787,14 @@ bool ScintillaCocoa::SyncPaint(void *gc, PRectangle rc) {
rcPaint = rc;
PRectangle rcText = GetTextRectangle();
paintingAllText = rcPaint.Contains(rcText);
- std::unique_ptr<Surface> sw(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr<Surface> sw(Surface::Allocate(Technology::Default));
CGContextSetAllowsAntialiasing((CGContextRef)gc,
- vs.extraFontFlag != SC_EFF_QUALITY_NON_ANTIALIASED);
+ vs.extraFontFlag != FontQuality::QualityNonAntialiased);
CGContextSetAllowsFontSmoothing((CGContextRef)gc,
- vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
+ vs.extraFontFlag == FontQuality::QualityLcdOptimized);
CGContextSetAllowsFontSubpixelPositioning((CGContextRef)gc,
- vs.extraFontFlag == SC_EFF_QUALITY_DEFAULT ||
- vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
+ vs.extraFontFlag == FontQuality::QualityDefault ||
+ vs.extraFontFlag == FontQuality::QualityLcdOptimized);
sw->Init(gc, wMain.GetID());
Paint(sw.get(), rc);
const bool succeeded = paintState != PaintState::abandoned;
@@ -1804,15 +1817,15 @@ void ScintillaCocoa::PaintMargin(NSRect aRect) {
PRectangle rc = NSRectToPRectangle(aRect);
rcPaint = rc;
- std::unique_ptr<Surface> sw(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr<Surface> sw(Surface::Allocate(Technology::Default));
if (sw) {
CGContextSetAllowsAntialiasing(gc,
- vs.extraFontFlag != SC_EFF_QUALITY_NON_ANTIALIASED);
+ vs.extraFontFlag != FontQuality::QualityNonAntialiased);
CGContextSetAllowsFontSmoothing(gc,
- vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
+ vs.extraFontFlag == FontQuality::QualityLcdOptimized);
CGContextSetAllowsFontSubpixelPositioning(gc,
- vs.extraFontFlag == SC_EFF_QUALITY_DEFAULT ||
- vs.extraFontFlag == SC_EFF_QUALITY_LCD_OPTIMIZED);
+ vs.extraFontFlag == FontQuality::QualityDefault ||
+ vs.extraFontFlag == FontQuality::QualityLcdOptimized);
sw->Init(gc, wMargin.GetID());
PaintSelMargin(sw.get(), rc);
sw->Release();
@@ -1995,7 +2008,7 @@ void ScintillaCocoa::RegisterNotifyCallback(intptr_t windowid, SciNotifyFunc cal
void ScintillaCocoa::NotifyChange() {
if (notifyProc != NULL)
- notifyProc(notifyObj, WM_COMMAND, Platform::LongFromTwoShorts(static_cast<short>(GetCtrlID()), SCEN_CHANGE),
+ notifyProc(notifyObj, WM_COMMAND, Platform::LongFromTwoShorts(static_cast<short>(GetCtrlID()), static_cast<short>(FocusChange::Change)),
(uintptr_t) this);
}
@@ -2004,7 +2017,7 @@ void ScintillaCocoa::NotifyChange() {
void ScintillaCocoa::NotifyFocus(bool focus) {
if (commandEvents && notifyProc)
notifyProc(notifyObj, WM_COMMAND, Platform::LongFromTwoShorts(static_cast<short>(GetCtrlID()),
- (focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS)),
+ static_cast<short>((focus ? FocusChange::Setfocus : FocusChange::Killfocus))),
(uintptr_t) this);
Editor::NotifyFocus(focus);
@@ -2018,19 +2031,19 @@ void ScintillaCocoa::NotifyFocus(bool focus) {
*
* @param scn The notification to send.
*/
-void ScintillaCocoa::NotifyParent(SCNotification scn) {
+void ScintillaCocoa::NotifyParent(NotificationData scn) {
scn.nmhdr.hwndFrom = (void *) this;
scn.nmhdr.idFrom = GetCtrlID();
if (notifyProc != NULL)
notifyProc(notifyObj, WM_NOTIFY, GetCtrlID(), (uintptr_t) &scn);
if (delegate)
- [delegate notification: &scn];
- if (scn.nmhdr.code == SCN_UPDATEUI) {
+ [delegate notification: reinterpret_cast<SCNotification *>(&scn)];
+ if (scn.nmhdr.code == Notification::UpdateUI) {
NSView *content = ContentView();
- if (scn.updated & SC_UPDATE_CONTENT) {
+ if (FlagSet(scn.updated, Update::Content)) {
NSAccessibilityPostNotification(content, NSAccessibilityValueChangedNotification);
}
- if (scn.updated & SC_UPDATE_SELECTION) {
+ if (FlagSet(scn.updated, Update::Selection)) {
NSAccessibilityPostNotification(content, NSAccessibilitySelectedTextChangedNotification);
}
}
@@ -2039,8 +2052,8 @@ void ScintillaCocoa::NotifyParent(SCNotification scn) {
//--------------------------------------------------------------------------------------------------
void ScintillaCocoa::NotifyURIDropped(const char *uri) {
- SCNotification scn;
- scn.nmhdr.code = SCN_URIDROPPED;
+ NotificationData scn;
+ scn.nmhdr.code = Notification::URIDropped;
scn.text = uri;
NotifyParent(scn);
@@ -2099,55 +2112,55 @@ bool ScintillaCocoa::Draw(NSRect rect, CGContextRef gc) {
/**
* Helper function to translate OS X key codes to Scintilla key codes.
*/
-static inline UniChar KeyTranslate(UniChar unicodeChar, NSEventModifierFlags modifierFlags) {
+static inline Keys KeyTranslate(UniChar unicodeChar, NSEventModifierFlags modifierFlags) {
switch (unicodeChar) {
case NSDownArrowFunctionKey:
- return SCK_DOWN;
+ return Keys::Down;
case NSUpArrowFunctionKey:
- return SCK_UP;
+ return Keys::Up;
case NSLeftArrowFunctionKey:
- return SCK_LEFT;
+ return Keys::Left;
case NSRightArrowFunctionKey:
- return SCK_RIGHT;
+ return Keys::Right;
case NSHomeFunctionKey:
- return SCK_HOME;
+ return Keys::Home;
case NSEndFunctionKey:
- return SCK_END;
+ return Keys::End;
case NSPageUpFunctionKey:
- return SCK_PRIOR;
+ return Keys::Prior;
case NSPageDownFunctionKey:
- return SCK_NEXT;
+ return Keys::Next;
case NSDeleteFunctionKey:
- return SCK_DELETE;
+ return Keys::Delete;
case NSInsertFunctionKey:
- return SCK_INSERT;
+ return Keys::Insert;
case '\n':
case 3:
- return SCK_RETURN;
+ return Keys::Return;
case 27:
- return SCK_ESCAPE;
+ return Keys::Escape;
case '+':
if (modifierFlags & NSEventModifierFlagNumericPad)
- return SCK_ADD;
+ return Keys::Add;
else
- return unicodeChar;
+ return static_cast<Keys>(unicodeChar);
case '-':
if (modifierFlags & NSEventModifierFlagNumericPad)
- return SCK_SUBTRACT;
+ return Keys::Subtract;
else
- return unicodeChar;
+ return static_cast<Keys>(unicodeChar);
case '/':
if (modifierFlags & NSEventModifierFlagNumericPad)
- return SCK_DIVIDE;
+ return Keys::Divide;
else
- return unicodeChar;
+ return static_cast<Keys>(unicodeChar);
case 127:
- return SCK_BACK;
+ return Keys::Back;
case '\t':
case 25: // Shift tab, return to unmodified tab and handle that via modifiers.
- return SCK_TAB;
+ return Keys::Tab;
default:
- return unicodeChar;
+ return static_cast<Keys>(unicodeChar);
}
}
@@ -2159,13 +2172,13 @@ static inline UniChar KeyTranslate(UniChar unicodeChar, NSEventModifierFlags mod
* @param modifiers An integer bit set of NSSEvent modifier flags.
* @return A set of SCI_* modifier flags.
*/
-static int TranslateModifierFlags(NSUInteger modifiers) {
+static KeyMod TranslateModifierFlags(NSUInteger modifiers) {
// Signal Control as SCI_META
return
- (((modifiers & NSEventModifierFlagShift) != 0) ? SCI_SHIFT : 0) |
- (((modifiers & NSEventModifierFlagCommand) != 0) ? SCI_CTRL : 0) |
- (((modifiers & NSEventModifierFlagOption) != 0) ? SCI_ALT : 0) |
- (((modifiers & NSEventModifierFlagControl) != 0) ? SCI_META : 0);
+ (((modifiers & NSEventModifierFlagShift) != 0) ? KeyMod::Shift : KeyMod::Norm) |
+ (((modifiers & NSEventModifierFlagCommand) != 0) ? KeyMod::Ctrl : KeyMod::Norm) |
+ (((modifiers & NSEventModifierFlagOption) != 0) ? KeyMod::Alt : KeyMod::Norm) |
+ (((modifiers & NSEventModifierFlagControl) != 0) ? KeyMod::Meta : KeyMod::Norm);
}
//--------------------------------------------------------------------------------------------------
@@ -2188,7 +2201,7 @@ bool ScintillaCocoa::KeyboardInput(NSEvent *event) {
const UniChar originalKey = [input characterAtIndex: i];
NSEventModifierFlags modifierFlags = event.modifierFlags;
- UniChar key = KeyTranslate(originalKey, modifierFlags);
+ Keys key = KeyTranslate(originalKey, modifierFlags);
bool consumed = false; // Consumed as command?
@@ -2227,7 +2240,7 @@ ptrdiff_t ScintillaCocoa::InsertText(NSString *input, CharacterSource charSource
return encoded.length();
} else {
const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
ptrdiff_t lengthInserted = 0;
for (NSInteger i = 0; i < [input length]; i++) {
NSString *character = [input substringWithRange:NSMakeRange(i, 1)];
@@ -2248,10 +2261,10 @@ ptrdiff_t ScintillaCocoa::InsertText(NSString *input, CharacterSource charSource
*/
NSRange ScintillaCocoa::PositionsFromCharacters(NSRange rangeCharacters) const {
Sci::Position start = pdoc->GetRelativePositionUTF16(0, rangeCharacters.location);
- if (start == INVALID_POSITION)
+ if (start == Sci::invalidPosition)
start = pdoc->Length();
Sci::Position end = pdoc->GetRelativePositionUTF16(start, rangeCharacters.length);
- if (end == INVALID_POSITION)
+ if (end == Sci::invalidPosition)
end = pdoc->Length();
return NSMakeRange(start, end - start);
}
@@ -2318,7 +2331,7 @@ void ScintillaCocoa::CompositionStart() {
*/
void ScintillaCocoa::CompositionCommit() {
pdoc->TentativeCommit();
- pdoc->DecorationSetCurrentIndicator(INDICATOR_IME);
+ pdoc->DecorationSetCurrentIndicator(static_cast<int>(IndicatorNumbers::Ime));
pdoc->DecorationFillRange(0, 0, pdoc->Length());
}
@@ -2366,7 +2379,7 @@ unsigned int TimeOfEvent(NSEvent *event) {
*/
void ScintillaCocoa::MouseEntered(NSEvent *event) {
if (!HaveMouseCapture()) {
- WndProc(SCI_SETCURSOR, (long int)SC_CURSORNORMAL, 0);
+ WndProc(Message::SetCursor, (long int)CursorShape::Normal, 0);
// Mouse location is given in screen coordinates and might also be outside of our bounds.
Point location = ConvertPoint(event.locationInWindow);
@@ -2433,9 +2446,9 @@ void ScintillaCocoa::MouseWheel(NSEvent *event) {
// Zoom! We play with the font sizes in the styles.
// Number of steps/line is ignored, we just care if sizing up or down.
if (dY > 0.5)
- KeyCommand(SCI_ZOOMIN);
+ KeyCommand(Message::ZoomIn);
else if (dY < -0.5)
- KeyCommand(SCI_ZOOMOUT);
+ KeyCommand(Message::ZoomOut);
} else {
}
}
@@ -2449,7 +2462,7 @@ void ScintillaCocoa::SelectAll() {
}
void ScintillaCocoa::DeleteBackward() {
- KeyDownWithModifiers(SCK_BACK, 0, nil);
+ KeyDownWithModifiers(Keys::Back, KeyMod::Norm, nil);
}
void ScintillaCocoa::Cut() {
@@ -2467,11 +2480,11 @@ void ScintillaCocoa::Redo() {
//--------------------------------------------------------------------------------------------------
bool ScintillaCocoa::ShouldDisplayPopupOnMargin() {
- return displayPopupMenu == SC_POPUP_ALL;
+ return displayPopupMenu == PopUp::All;
}
bool ScintillaCocoa::ShouldDisplayPopupOnText() {
- return displayPopupMenu == SC_POPUP_ALL || displayPopupMenu == SC_POPUP_TEXT;
+ return displayPopupMenu == PopUp::All || displayPopupMenu == PopUp::Text;
}
/**
@@ -2557,18 +2570,18 @@ void ScintillaCocoa::UpdateBaseElements() {
NSColor *selBack = [NSColor.selectedTextBackgroundColor colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
// Additional selection: blend with text background to make weaker version.
NSColor *modified = [selBack blendedColorWithFraction:0.5 ofColor:textBack];
- changed = vs.SetElementBase(SC_ELEMENT_SELECTION_BACK, ColourFromNSColor(selBack));
- changed = vs.SetElementBase(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, ColourFromNSColor(modified)) || changed;
- changed = vs.SetElementBase(SC_ELEMENT_SELECTION_NO_FOCUS_BACK, ColourFromNSColor(noFocusBack)) || changed;
+ changed = vs.SetElementBase(Element::SelectionBack, ColourFromNSColor(selBack));
+ changed = vs.SetElementBase(Element::SelectionAdditionalBack, ColourFromNSColor(modified)) || changed;
+ changed = vs.SetElementBase(Element::SelectionNoFocusBack, ColourFromNSColor(noFocusBack)) || changed;
} else {
// Less translucent colour used in dark mode as otherwise less visible
const int alpha = textBack.brightnessComponent > 0.5 ? 0x40 : 0x60;
// Make a translucent colour that approximates selectedTextBackgroundColor
NSColor *accent = [NSColor.controlAccentColor colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
const ColourRGBA colourAccent = ColourFromNSColor(accent);
- changed = vs.SetElementBase(SC_ELEMENT_SELECTION_BACK, ColourRGBA(colourAccent, alpha));
- changed = vs.SetElementBase(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, ColourRGBA(colourAccent, alpha/2)) || changed;
- changed = vs.SetElementBase(SC_ELEMENT_SELECTION_NO_FOCUS_BACK, ColourRGBA(ColourFromNSColor(noFocusBack), alpha)) || changed;
+ changed = vs.SetElementBase(Element::SelectionBack, ColourRGBA(colourAccent, alpha));
+ changed = vs.SetElementBase(Element::SelectionAdditionalBack, ColourRGBA(colourAccent, alpha/2)) || changed;
+ changed = vs.SetElementBase(Element::SelectionNoFocusBack, ColourRGBA(ColourFromNSColor(noFocusBack), alpha)) || changed;
}
}
@@ -2614,7 +2627,7 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining
if (charRange.length) {
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
std::vector<char> buffer(charRange.length);
pdoc->GetCharRange(&buffer[0], charRange.location, charRange.length);
@@ -2624,18 +2637,18 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining
CFRelease(cfsFind);
layerFindIndicator.retaining = retaining;
layerFindIndicator.positionFind = charRange.location;
- // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles
- const char styleByte = static_cast<char>(WndProc(SCI_GETSTYLEAT, charRange.location, 0));
+ // Message::GetStyleAt reports a signed byte but want an unsigned to index into styles
+ const char styleByte = static_cast<char>(WndProc(Message::GetStyleAt, charRange.location, 0));
const long style = static_cast<unsigned char>(styleByte);
- std::vector<char> bufferFontName(WndProc(SCI_STYLEGETFONT, style, 0) + 1);
- WndProc(SCI_STYLEGETFONT, style, (sptr_t)&bufferFontName[0]);
+ std::vector<char> bufferFontName(WndProc(Message::StyleGetFont, style, 0) + 1);
+ WndProc(Message::StyleGetFont, style, (sptr_t)&bufferFontName[0]);
layerFindIndicator.sFont = @(&bufferFontName[0]);
- layerFindIndicator.fontSize = WndProc(SCI_STYLEGETSIZEFRACTIONAL, style, 0) /
- (float)SC_FONT_SIZE_MULTIPLIER;
- layerFindIndicator.widthText = WndProc(SCI_POINTXFROMPOSITION, 0, charRange.location + charRange.length) -
- WndProc(SCI_POINTXFROMPOSITION, 0, charRange.location);
- layerFindIndicator.heightLine = WndProc(SCI_TEXTHEIGHT, 0, 0);
+ layerFindIndicator.fontSize = WndProc(Message::StyleGetSizeFractional, style, 0) /
+ (float)FontSizeMultiplier;
+ layerFindIndicator.widthText = WndProc(Message::PointXFromPosition, 0, charRange.location + charRange.length) -
+ WndProc(Message::PointXFromPosition, 0, charRange.location);
+ layerFindIndicator.heightLine = WndProc(Message::TextHeight, 0, 0);
MoveFindIndicatorWithBounce(YES);
} else {
[layerFindIndicator hideMatch];
@@ -2647,8 +2660,8 @@ void ScintillaCocoa::MoveFindIndicatorWithBounce(BOOL bounce) {
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
if (layerFindIndicator) {
CGPoint ptText = CGPointMake(
- WndProc(SCI_POINTXFROMPOSITION, 0, layerFindIndicator.positionFind),
- WndProc(SCI_POINTYFROMPOSITION, 0, layerFindIndicator.positionFind));
+ WndProc(Message::PointXFromPosition, 0, layerFindIndicator.positionFind),
+ WndProc(Message::PointYFromPosition, 0, layerFindIndicator.positionFind));
ptText.x = ptText.x - vs.fixedColumnWidth + xOffset;
ptText.y += topLine * vs.lineHeight;
if (!layerFindIndicator.geometryFlipped) {
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm
index f878a7a6b..f82872d65 100644
--- a/cocoa/ScintillaView.mm
+++ b/cocoa/ScintillaView.mm
@@ -16,6 +16,10 @@
#include <vector>
#include <optional>
+#import "ScintillaTypes.h"
+#import "ScintillaMessages.h"
+#import "ScintillaStructures.h"
+
#import "Debugging.h"
#import "Geometry.h"
#import "Platform.h"
@@ -23,11 +27,12 @@
#import "ScintillaCocoa.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
// Add backend property to ScintillaView as a private category.
// Specified here as backend accessed by SCIMarginView and SCIContentView.
@interface ScintillaView()
-@property(nonatomic, readonly) Scintilla::ScintillaCocoa *backend;
+@property(nonatomic, readonly) Scintilla::Internal::ScintillaCocoa *backend;
@end
// Two additional cursors we need, which aren't provided by Cocoa.
@@ -181,8 +186,8 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
NSRect marginRect = self.bounds;
size_t co = currentCursors.count;
for (size_t i=0; i<co; i++) {
- long cursType = owner.backend->WndProc(SCI_GETMARGINCURSORN, i, 0);
- long width =owner.backend->WndProc(SCI_GETMARGINWIDTHN, i, 0);
+ long cursType = owner.backend->WndProc(Message::GetMarginCursorN, i, 0);
+ long width =owner.backend->WndProc(Message::GetMarginWidthN, i, 0);
NSCursor *cc = cursorFromEnum(static_cast<Window::Cursor>(cursType));
currentCursors[i] = cc;
marginRect.origin.x = x;
@@ -464,7 +469,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
const long position = [mOwner message: SCI_CHARPOSITIONFROMPOINT
wParam: rectLocal.origin.x
lParam: rectLocal.origin.y];
- if (position == INVALID_POSITION) {
+ if (position == Sci::invalidPosition) {
return NSNotFound;
} else {
const NSRange index = mOwner.backend->CharactersFromPositions(NSMakeRange(position, 0));
@@ -546,7 +551,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
else if ([aString isKindOfClass: [NSAttributedString class]])
newText = (NSString *) [aString string];
- mOwner.backend->InsertText(newText, EditModel::CharacterSource::directInput);
+ mOwner.backend->InsertText(newText, CharacterSource::DirectInput);
}
//--------------------------------------------------------------------------------------------------
@@ -639,7 +644,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
NSRange posRangeCurrent = mOwner.backend->PositionsFromCharacters(NSMakeRange(replacementRange.location, 0));
// Note: Scintilla internally works almost always with bytes instead chars, so we need to take
// this into account when determining selection ranges and such.
- ptrdiff_t lengthInserted = mOwner.backend->InsertText(newText, EditModel::CharacterSource::tentativeInput);
+ ptrdiff_t lengthInserted = mOwner.backend->InsertText(newText, CharacterSource::TentativeInput);
posRangeCurrent.length = lengthInserted;
mMarkedTextRange = mOwner.backend->CharactersFromPositions(posRangeCurrent);
// Mark the just inserted text. Keep the marked range for later reset.
@@ -764,7 +769,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
if ((rc.origin.y > 0) && (NSMaxY(rc) < contentRect.size.height)) {
// Only snap for positions inside the document - allow outside
// for overshoot.
- long lineHeight = mOwner.backend->WndProc(SCI_TEXTHEIGHT, 0, 0);
+ long lineHeight = mOwner.backend->WndProc(Message::TextHeight, 0, 0);
rc.origin.y = std::round(static_cast<XYPOSITION>(rc.origin.y) / lineHeight) * lineHeight;
}
// Snap to whole points - on retina displays this avoids visual debris
@@ -826,7 +831,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
operation: (NSDragOperation) operation {
#pragma unused(session, screenPoint)
if (operation == NSDragOperationDelete) {
- mOwner.backend->WndProc(SCI_CLEAR, 0, 0);
+ mOwner.backend->WndProc(Message::Clear, 0, 0);
}
}
@@ -960,7 +965,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
}
- (BOOL) isEditable {
- return mOwner.backend->WndProc(SCI_GETREADONLY, 0, 0) == 0;
+ return mOwner.backend->WndProc(Message::GetReadOnly, 0, 0) == 0;
}
#pragma mark - NSAccessibility
@@ -1189,7 +1194,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
@implementation ScintillaView {
// The back end is kind of a controller and model in one.
// It uses the content view for display.
- Scintilla::ScintillaCocoa *mBackend;
+ Scintilla::Internal::ScintillaCocoa *mBackend;
// This is the actual content to which the backend renders itself.
SCIContentView *mContent;
@@ -1339,12 +1344,13 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
if (mDelegate != nil) {
[mDelegate notification: scn];
- if (scn->nmhdr.code != SCN_ZOOM && scn->nmhdr.code != SCN_UPDATEUI)
+ if (scn->nmhdr.code != static_cast<unsigned int>(Notification::Zoom) &&
+ scn->nmhdr.code != static_cast<unsigned int>(Notification::UpdateUI))
return;
}
- switch (scn->nmhdr.code) {
- case SCN_MARGINCLICK: {
+ switch (static_cast<Notification>(scn->nmhdr.code)) {
+ case Notification::MarginClick: {
if (scn->margin == 2) {
// Click on the folder margin. Toggle the current line if possible.
long line = [self getGeneralProperty: SCI_LINEFROMPOSITION parameter: scn->position];
@@ -1352,14 +1358,15 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
}
break;
};
- case SCN_MODIFIED: {
+ case Notification::Modified: {
// Decide depending on the modification type what to do.
// There can be more than one modification carried by one notification.
- if (scn->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT))
+ if (scn->modificationType &
+ static_cast<int>((ModificationFlags::InsertText | ModificationFlags::DeleteText)))
[self sendNotification: NSTextDidChangeNotification];
break;
}
- case SCN_ZOOM: {
+ case Notification::Zoom: {
// A zoom change happened. Notify info bar if there is one.
float zoom = [self getGeneralProperty: SCI_GETZOOM parameter: 0];
long fontSize = [self getGeneralProperty: SCI_STYLEGETSIZE parameter: STYLE_DEFAULT];
@@ -1367,21 +1374,23 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
[mInfoBar notify: IBNZoomChanged message: nil location: NSZeroPoint value: factor];
break;
}
- case SCN_UPDATEUI: {
+ case Notification::UpdateUI: {
// Triggered whenever changes in the UI state need to be reflected.
// These can be: caret changes, selection changes etc.
NSPoint caretPosition = mBackend->GetCaretPosition();
[mInfoBar notify: IBNCaretChanged message: nil location: caretPosition value: 0];
[self sendNotification: SCIUpdateUINotification];
- if (scn->updated & (SC_UPDATE_SELECTION | SC_UPDATE_CONTENT)) {
+ if (scn->updated & static_cast<int>((Update::Selection | Update::Content))) {
[self sendNotification: NSTextViewDidChangeSelectionNotification];
}
break;
}
- case SCN_FOCUSOUT:
+ case Notification::FocusOut:
[self sendNotification: NSTextDidEndEditingNotification];
break;
- case SCN_FOCUSIN: // Nothing to do for now.
+ case Notification::FocusIn: // Nothing to do for now.
+ break;
+ default:
break;
}
}
@@ -1614,11 +1623,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
- (NSString *) selectedString {
NSString *result = @"";
- const long length = mBackend->WndProc(SCI_GETSELTEXT, 0, 0);
+ const long length = mBackend->WndProc(Message::GetSelText, 0, 0);
if (length > 0) {
std::string buffer(length + 1, '\0');
try {
- mBackend->WndProc(SCI_GETSELTEXT, length + 1, (sptr_t) &buffer[0]);
+ mBackend->WndProc(Message::GetSelText, length + 1, (sptr_t) &buffer[0]);
result = @(buffer.c_str());
} catch (...) {
@@ -1649,11 +1658,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
- (NSString *) string {
NSString *result = @"";
- const long length = mBackend->WndProc(SCI_GETLENGTH, 0, 0);
+ const long length = mBackend->WndProc(Message::GetLength, 0, 0);
if (length > 0) {
std::string buffer(length + 1, '\0');
try {
- mBackend->WndProc(SCI_GETTEXT, length + 1, (sptr_t) &buffer[0]);
+ mBackend->WndProc(Message::GetText, length + 1, (sptr_t) &buffer[0]);
result = @(buffer.c_str());
} catch (...) {
@@ -1670,26 +1679,26 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
*/
- (void) setString: (NSString *) aString {
const char *text = aString.UTF8String;
- mBackend->WndProc(SCI_SETTEXT, 0, (long) text);
+ mBackend->WndProc(Message::SetText, 0, (long) text);
}
//--------------------------------------------------------------------------------------------------
- (void) insertString: (NSString *) aString atOffset: (int) offset {
const char *text = aString.UTF8String;
- mBackend->WndProc(SCI_ADDTEXT, offset, (long) text);
+ mBackend->WndProc(Message::AddText, offset, (long) text);
}
//--------------------------------------------------------------------------------------------------
- (void) setEditable: (BOOL) editable {
- mBackend->WndProc(SCI_SETREADONLY, editable ? 0 : 1, 0);
+ mBackend->WndProc(Message::SetReadOnly, editable ? 0 : 1, 0);
}
//--------------------------------------------------------------------------------------------------
- (BOOL) isEditable {
- return mBackend->WndProc(SCI_GETREADONLY, 0, 0) == 0;
+ return mBackend->WndProc(Message::GetReadOnly, 0, 0) == 0;
}
//--------------------------------------------------------------------------------------------------
@@ -1718,15 +1727,15 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
}
- (sptr_t) message: (unsigned int) message wParam: (uptr_t) wParam lParam: (sptr_t) lParam {
- return mBackend->WndProc(message, wParam, lParam);
+ return mBackend->WndProc(static_cast<Message>(message), wParam, lParam);
}
- (sptr_t) message: (unsigned int) message wParam: (uptr_t) wParam {
- return mBackend->WndProc(message, wParam, 0);
+ return mBackend->WndProc(static_cast<Message>(message), wParam, 0);
}
- (sptr_t) message: (unsigned int) message {
- return mBackend->WndProc(message, 0, 0);
+ return mBackend->WndProc(static_cast<Message>(message), 0, 0);
}
//--------------------------------------------------------------------------------------------------
@@ -1739,7 +1748,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* @param value The actual value. It depends on the property what this parameter means.
*/
- (void) setGeneralProperty: (int) property parameter: (long) parameter value: (long) value {
- mBackend->WndProc(property, parameter, value);
+ mBackend->WndProc(static_cast<Message>(property), parameter, value);
}
//--------------------------------------------------------------------------------------------------
@@ -1751,7 +1760,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* @param value The actual value. It depends on the property what this parameter means.
*/
- (void) setGeneralProperty: (int) property value: (long) value {
- mBackend->WndProc(property, value, 0);
+ mBackend->WndProc(static_cast<Message>(property), value, 0);
}
//--------------------------------------------------------------------------------------------------
@@ -1765,7 +1774,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* @result A generic value which must be interpreted depending on the property queried.
*/
- (long) getGeneralProperty: (int) property parameter: (long) parameter extra: (long) extra {
- return mBackend->WndProc(property, parameter, extra);
+ return mBackend->WndProc(static_cast<Message>(property), parameter, extra);
}
//--------------------------------------------------------------------------------------------------
@@ -1774,7 +1783,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* Convenience function to avoid unneeded extra parameter.
*/
- (long) getGeneralProperty: (int) property parameter: (long) parameter {
- return mBackend->WndProc(property, parameter, 0);
+ return mBackend->WndProc(static_cast<Message>(property), parameter, 0);
}
//--------------------------------------------------------------------------------------------------
@@ -1783,7 +1792,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* Convenience function to avoid unneeded parameters.
*/
- (long) getGeneralProperty: (int) property {
- return mBackend->WndProc(property, 0, 0);
+ return mBackend->WndProc(static_cast<Message>(property), 0, 0);
}
//--------------------------------------------------------------------------------------------------
@@ -1792,7 +1801,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* Use this variant if you have to pass in a reference to something (e.g. a text range).
*/
- (long) getGeneralProperty: (int) property ref: (const void *) ref {
- return mBackend->WndProc(property, 0, (sptr_t) ref);
+ return mBackend->WndProc(static_cast<Message>(property), 0, (sptr_t) ref);
}
//--------------------------------------------------------------------------------------------------
@@ -1808,7 +1817,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
long blue = static_cast<long>(value.blueComponent * 255);
long color = (blue << 16) + (green << 8) + red;
- mBackend->WndProc(property, parameter, color);
+ mBackend->WndProc(static_cast<Message>(property), parameter, color);
}
//--------------------------------------------------------------------------------------------------
@@ -1851,7 +1860,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
[[NSScanner scannerWithString: @(value)] scanHexInt: &rawBlue];
long color = (rawBlue << 16) + (rawGreen << 8) + rawRed;
- mBackend->WndProc(property, parameter, color);
+ mBackend->WndProc(static_cast<Message>(property), parameter, color);
}
}
@@ -1861,7 +1870,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* Specialized property getter for colors.
*/
- (NSColor *) getColorProperty: (int) property parameter: (long) parameter {
- long color = mBackend->WndProc(property, parameter, 0);
+ long color = mBackend->WndProc(static_cast<Message>(property), parameter, 0);
CGFloat red = (color & 0xFF) / 255.0;
CGFloat green = ((color >> 8) & 0xFF) / 255.0;
CGFloat blue = ((color >> 16) & 0xFF) / 255.0;
@@ -1875,7 +1884,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* Specialized property setter for references (pointers, addresses).
*/
- (void) setReferenceProperty: (int) property parameter: (long) parameter value: (const void *) value {
- mBackend->WndProc(property, parameter, (sptr_t) value);
+ mBackend->WndProc(static_cast<Message>(property), parameter, (sptr_t) value);
}
//--------------------------------------------------------------------------------------------------
@@ -1884,7 +1893,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* Specialized property getter for references (pointers, addresses).
*/
- (const void *) getReferenceProperty: (int) property parameter: (long) parameter {
- return (const void *) mBackend->WndProc(property, parameter, 0);
+ return (const void *) mBackend->WndProc(static_cast<Message>(property), parameter, 0);
}
//--------------------------------------------------------------------------------------------------
@@ -1894,7 +1903,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
*/
- (void) setStringProperty: (int) property parameter: (long) parameter value: (NSString *) value {
const char *rawValue = value.UTF8String;
- mBackend->WndProc(property, parameter, (sptr_t) rawValue);
+ mBackend->WndProc(static_cast<Message>(property), parameter, (sptr_t) rawValue);
}
@@ -1904,7 +1913,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
* Specialized property getter for string values.
*/
- (NSString *) getStringProperty: (int) property parameter: (long) parameter {
- const char *rawValue = (const char *) mBackend->WndProc(property, parameter, 0);
+ const char *rawValue = (const char *) mBackend->WndProc(static_cast<Message>(property), parameter, 0);
return @(rawValue);
}
@@ -1916,7 +1925,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
- (void) setLexerProperty: (NSString *) name value: (NSString *) value {
const char *rawName = name.UTF8String;
const char *rawValue = value.UTF8String;
- mBackend->WndProc(SCI_SETPROPERTY, (sptr_t) rawName, (sptr_t) rawValue);
+ mBackend->WndProc(Message::SetProperty, (sptr_t) rawName, (sptr_t) rawValue);
}
//--------------------------------------------------------------------------------------------------
@@ -1926,7 +1935,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
*/
- (NSString *) getLexerProperty: (NSString *) name {
const char *rawName = name.UTF8String;
- const char *result = (const char *) mBackend->WndProc(SCI_SETPROPERTY, (sptr_t) rawName, 0);
+ const char *result = (const char *) mBackend->WndProc(Message::SetProperty, (sptr_t) rawName, 0);
return @(result);
}
@@ -1996,9 +2005,9 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
- (void) insertText: (id) aString {
if ([aString isKindOfClass: [NSString class]])
- mBackend->InsertText(aString, EditModel::CharacterSource::directInput);
+ mBackend->InsertText(aString, CharacterSource::DirectInput);
else if ([aString isKindOfClass: [NSAttributedString class]])
- mBackend->InsertText([aString string], EditModel::CharacterSource::directInput);
+ mBackend->InsertText([aString string], CharacterSource::DirectInput);
}
//--------------------------------------------------------------------------------------------------
@@ -2032,11 +2041,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
scrollTo: (BOOL) scrollTo
wrap: (BOOL) wrap
backwards: (BOOL) backwards {
- int searchFlags= 0;
+ FindOption searchFlags = FindOption::None;
if (matchCase)
- searchFlags |= SCFIND_MATCHCASE;
+ searchFlags = searchFlags | FindOption::MatchCase;
if (wholeWord)
- searchFlags |= SCFIND_WHOLEWORD;
+ searchFlags = searchFlags | FindOption::WholeWord;
long selectionStart = [self getGeneralProperty: SCI_GETSELECTIONSTART parameter: 0];
long selectionEnd = [self getGeneralProperty: SCI_GETSELECTIONEND parameter: 0];
@@ -2055,7 +2064,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
if (backwards) {
result = [ScintillaView directCall: self
message: SCI_SEARCHPREV
- wParam: searchFlags
+ wParam: (uptr_t) searchFlags
lParam: (sptr_t) textToSearch];
if (result < 0 && wrap) {
// Try again from the end of the document if nothing could be found so far and
@@ -2064,13 +2073,13 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
[self setGeneralProperty: SCI_SEARCHANCHOR value: 0];
result = [ScintillaView directCall: self
message: SCI_SEARCHNEXT
- wParam: searchFlags
+ wParam: (uptr_t) searchFlags
lParam: (sptr_t) textToSearch];
}
} else {
result = [ScintillaView directCall: self
message: SCI_SEARCHNEXT
- wParam: searchFlags
+ wParam: (uptr_t) searchFlags
lParam: (sptr_t) textToSearch];
if (result < 0 && wrap) {
// Try again from the start of the document if nothing could be found so far and
@@ -2079,7 +2088,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
[self setGeneralProperty: SCI_SEARCHANCHOR value: 0];
result = [ScintillaView directCall: self
message: SCI_SEARCHNEXT
- wParam: searchFlags
+ wParam: (uptr_t) searchFlags
lParam: (sptr_t) textToSearch];
}
}
@@ -2117,12 +2126,12 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
startPosition = [self getGeneralProperty: SCI_GETCURRENTPOS];
long endPosition = [self getGeneralProperty: SCI_GETTEXTLENGTH];
- int searchFlags= 0;
+ FindOption searchFlags = FindOption::None;
if (matchCase)
- searchFlags |= SCFIND_MATCHCASE;
+ searchFlags = searchFlags | FindOption::MatchCase;
if (wholeWord)
- searchFlags |= SCFIND_WHOLEWORD;
- [self setGeneralProperty: SCI_SETSEARCHFLAGS value: searchFlags];
+ searchFlags = searchFlags | FindOption::WholeWord;
+ [self setGeneralProperty: SCI_SETSEARCHFLAGS value: (long)searchFlags];
[self setGeneralProperty: SCI_SETTARGETSTART value: startPosition];
[self setGeneralProperty: SCI_SETTARGETEND value: endPosition];
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 43fcab2dc..d1abef8de 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -128,7 +128,7 @@
<h1>Scintilla Documentation</h1>
- <p>Last edited 13 May 2021 NH</p>
+ <p>Last edited 25 May 2021 NH</p>
<p style="background:#90F0C0">Scintilla 5 has moved the lexers from Scintilla into a new
<a href="Lexilla.html">Lexilla</a> project.<br />
@@ -181,6 +181,12 @@
work out how to develop using Scintilla is to see how SciTE uses it. SciTE exercises most of
Scintilla's facilities.</p>
+ <p>There is a more type-safe binding of this API that can be used from C++.
+ It is implemented in the ScintillaTypes.h, ScintillaMessages.h, and ScintillaStructures.h headers.
+ SciTE contains (in src) a ScintillaCall module that can help further and will, in the future, be
+ moved into Scintilla.
+ </p>
+
<p>In the descriptions that follow, the messages are described as function calls with zero, one
or two arguments. These two arguments are the standard <code>wParam</code> and
<code>lParam</code> familiar to Windows programmers. These parameters are integers that
@@ -274,9 +280,9 @@
<th align="left" id="alpha"><code>alpha</code></th>
<td>Translucency is set using an alpha value.
- Alpha ranges from 0 (SC_ALPHA_TRANSPARENT) which is completely transparent to
- 255 (SC_ALPHA_OPAQUE) which is opaque.
- Previous versions used the value 256 (SC_ALPHA_NOALPHA) to indicate that drawing was to be
+ Alpha ranges from 0 (<code>SC_ALPHA_TRANSPARENT</code>) which is completely transparent to
+ 255 (<code>SC_ALPHA_OPAQUE</code>) which is opaque.
+ Previous versions used the value 256 (<code>SC_ALPHA_NOALPHA</code>) to indicate that drawing was to be
performed opaquely on the base layer. This is now discouraged and code should use the <code>&hellip;LAYER&hellip;</code>
methods to choose the layer.</td>
</tr>
@@ -1649,9 +1655,9 @@ struct Sci_TextToFind {
working in terms of UTF-16 code units.</p>
<p><b id="SCI_GETLINECHARACTERINDEX">SCI_GETLINECHARACTERINDEX &rarr; int</b><br />
- Returns which if any indexes are active. It may be <code>SC_LINECHARACTERINDEX_NONE(0)</code> or one or more
- of <code>SC_LINECHARACTERINDEX_UTF32(1)</code> if whole characters are indexed or
- <code>SC_LINECHARACTERINDEX_UTF16(2)</code> if UTF-16 code units are indexed.
+ Returns which if any indexes are active. It may be <code>SC_LINECHARACTERINDEX_NONE</code> (0) or one or more
+ of <code>SC_LINECHARACTERINDEX_UTF32</code> (1) if whole characters are indexed or
+ <code>SC_LINECHARACTERINDEX_UTF16</code> (2) if UTF-16 code units are indexed.
Character indexes are currently only supported for UTF-8 documents.</p>
<p><b id="SCI_ALLOCATELINECHARACTERINDEX">SCI_ALLOCATELINECHARACTERINDEX(int lineCharacterIndex)</b><br />
@@ -1665,7 +1671,7 @@ struct Sci_TextToFind {
<p><b id="SCI_LINEFROMINDEXPOSITION">SCI_LINEFROMINDEXPOSITION(position pos, int lineCharacterIndex) &rarr; line</b><br />
<b id="SCI_INDEXPOSITIONFROMLINE">SCI_INDEXPOSITIONFROMLINE(line line, int lineCharacterIndex) &rarr; position</b><br />
The document line of a particular character or code unit may be found by calling <code>SCI_LINEFROMINDEXPOSITION</code> with one of
- <code>SC_LINECHARACTERINDEX_UTF32(1)</code> or <code>SC_LINECHARACTERINDEX_UTF16(2)</code>.
+ <code>SC_LINECHARACTERINDEX_UTF32</code> (1) or <code>SC_LINECHARACTERINDEX_UTF16</code> (2).
The inverse action, finds the starting position of a document line either in characters or code units from the document start by calling
<code>SCI_INDEXPOSITIONFROMLINE</code> with the same <code class="parameter">lineCharacterIndex</code> argument.</p>
@@ -3722,7 +3728,7 @@ struct Sci_TextToFind {
<p><b id="SCI_SETCARETSTYLE">SCI_SETCARETSTYLE(int caretStyle)</b><br />
<b id="SCI_GETCARETSTYLE">SCI_GETCARETSTYLE &rarr; int</b><br />
The style of the caret can be set with <code>SCI_SETCARETSTYLE</code>.
- There are separate styles for insert mode (lower 4-bits, CARETSTYLE_INS_MASK) and
+ There are separate styles for insert mode (lower 4-bits, <code>CARETSTYLE_INS_MASK</code>) and
overtype mode (bit 4).
<table class="standard" summary="Caret Styles">
@@ -4457,7 +4463,7 @@ struct Sci_TextToFind {
<code>SC_EFF_QUALITY_ANTIALIASED</code>,
<code>SC_EFF_QUALITY_LCD_OPTIMIZED</code>.</p>
<p>In case it is necessary to squeeze more options into this property, only a limited number of bits defined
- by SC_EFF_QUALITY_MASK (0xf) will be used for quality.</p>
+ by <code>SC_EFF_QUALITY_MASK</code> (0xF) will be used for quality.</p>
<p><b id="SCI_SETCODEPAGE">SCI_SETCODEPAGE(int codePage)</b><br />
<b id="SCI_GETCODEPAGE">SCI_GETCODEPAGE &rarr; int</b><br />
@@ -4508,7 +4514,8 @@ struct Sci_TextToFind {
Currently, there is experimental support for bidirectional text on Win32 using DirectWrite and on macOS using Cocoa.
Only UTF-8 documents will show bidirectional behaviour and only in <code>SC_BIDIRECTIONAL_L2R</code> mode.
Some features, such as virtual space may not work with
- bidirectional text or may work only in some circumstances.</p>
+ bidirectional text or may work only in some circumstances.
+ <code>SC_BIDIRECTIONAL_R2L</code> may be implemented in the future.</p>
<p>There are additional processing and storage costs to bidirectional text.
As some applications may not want to pay the costs, bidirectional support must be explicitly enabled by calling
<code>SCI_SETBIDIRECTIONAL(SC_BIDIRECTIONAL_L2R)</code> (1) which chooses left to right as the default direction or
@@ -5169,7 +5176,7 @@ struct Sci_TextToFind {
They may also be invisible when used to track pieces of content for the application as <code>INDIC_HIDDEN</code>.</p>
<p>The <code>SCI_INDIC*</code> messages allow you to get and set the visual appearance of the
- indicators. They all use an <code class="parameter">indicator</code> argument in the range 0 to INDICATOR_MAX(35)
+ indicators. They all use an <code class="parameter">indicator</code> argument in the range 0 to <code>INDICATOR_MAX</code>(35)
to set the indicator to style. To prevent interference the set of indicators is divided up into a range for use
by lexers (0..7) a range for use by containers
(8=<code>INDICATOR_CONTAINER</code> .. 31=<code>INDICATOR_IME-1</code>)
@@ -5525,7 +5532,8 @@ struct Sci_TextToFind {
These messages set and get the flags associated with an indicator.
There is currently one flag defined, <code>SC_INDICFLAG_VALUEFORE</code>: when this flag is set
the colour used by the indicator is not from the indicator's fore setting but instead from the value of the indicator at
- that point in the file. This allows many colours to be displayed for a single indicator. The value is an <a class="jump"
+ that point in the file. <code>SC_INDICFLAG_NONE</code> is the default.
+ This allows many colours to be displayed for a single indicator. The value is an <a class="jump"
href="#colour">RGB integer colour</a> that has been ored with <code>SC_INDICVALUEBIT</code>(0x1000000)
when calling <a class="seealso" href="#SCI_SETINDICATORVALUE">SCI_SETINDICATORVALUE</a>.
To find the colour from the value, and the value with <code>SC_INDICVALUEMASK</code>(0xFFFFFF).
@@ -6941,8 +6949,9 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
allows it to be treated slightly different then its level may indicate. For example, blank
lines should generally not be fold points and will be considered part of the preceding section even though
they may have a lesser fold level.
- <code>SC_FOLDLEVELHEADERFLAG</code> indicates that
- the line is a header (fold point).</p>
+ <code>SC_FOLDLEVELHEADERFLAG</code> indicates that the line is a header (fold point).
+ <code>SC_FOLDLEVELNONE</code> is a default level that may occur before folding.
+ </p>
<p>Use <code>SCI_GETFOLDLEVEL(line) &amp; SC_FOLDLEVELNUMBERMASK</code> to get the fold level
of a line. Likewise, use <code>SCI_GETFOLDLEVEL(line) &amp; SC_FOLDLEVEL*FLAG</code> to get the
@@ -6972,6 +6981,12 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<tbody valign="top">
<tr>
+ <td align="left">SC_FOLDFLAG_NONE</td>
+ <td align="left">0</td>
+ <td align="left">Default value.</td>
+ </tr>
+
+ <tr>
<td align="left"></td>
<td align="left">1</td>
<td align="left">Experimental feature that has been removed.</td>
@@ -6980,44 +6995,38 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<tr>
<td align="left">SC_FOLDFLAG_LINEBEFORE_EXPANDED</td>
<td align="left">2</td>
-
<td align="left">Draw above if expanded</td>
</tr>
<tr>
<td align="left">SC_FOLDFLAG_LINEBEFORE_CONTRACTED</td>
<td align="left">4</td>
-
<td align="left">Draw above if not expanded</td>
</tr>
<tr>
<td align="left">SC_FOLDFLAG_LINEAFTER_EXPANDED</td>
<td align="left">8</td>
-
<td align="left">Draw below if expanded</td>
</tr>
<tr>
<td align="left">SC_FOLDFLAG_LINEAFTER_CONTRACTED</td>
<td align="left">16</td>
-
<td align="left">Draw below if not expanded</td>
</tr>
<tr>
<td align="left">SC_FOLDFLAG_LEVELNUMBERS</td>
<td align="left">64</td>
-
- <td align="left">display hexadecimal fold levels in line margin to aid debugging of
+ <td align="left">Display hexadecimal fold levels in line margin to aid debugging of
folding. The appearance of this feature may change in the future.</td>
</tr>
<tr>
<td align="left">SC_FOLDFLAG_LINESTATE</td>
<td align="left">128</td>
-
- <td align="left">display hexadecimal line state in line margin to aid debugging of lexing and folding.
+ <td align="left">Display hexadecimal line state in line margin to aid debugging of lexing and folding.
May not be used at the same time as <code>SC_FOLDFLAG_LEVELNUMBERS</code>.</td>
</tr>
</tbody>
@@ -7174,6 +7183,12 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<tbody valign="top">
<tr>
+ <td align="left">SC_AUTOMATICFOLD_NONE</td>
+ <td align="left">0</td>
+ <td align="left">Value with no automatic behaviour.</td>
+ </tr>
+
+ <tr>
<td align="left">SC_AUTOMATICFOLD_SHOW</td>
<td align="left">1</td>
<td align="left">Automatically show lines as needed.
@@ -8310,6 +8325,16 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber);
</tbody>
<tbody valign="top">
+
+ <tr>
+ <td align="left"><code>SC_UPDATE_NONE</code></td>
+
+ <td align="center">0x00</td>
+
+ <td>Value without any changes.</td>
+
+ </tr>
+
<tr>
<td align="left"><code>SC_UPDATE_CONTENT</code></td>
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 4d8d0dcda..b157ee805 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -581,6 +581,10 @@
Released 23 April 2021.
</li>
<li>
+ A more type-safe binding of Scintilla's API that can be used from C++ is implemented in the
+ ScintillaTypes.h, ScintillaMessages.h, and ScintillaStructures.h headers.
+ </li>
+ <li>
Change the way that selections and carets are drawn to use the element APIs.
The selection background colour may default to use platform APIs to discover global
or user settings and may change in response to those settings changing.
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index db1afc170..7a53bc28e 100755
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -24,6 +24,9 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
@@ -41,6 +44,7 @@
#endif
using namespace Scintilla;
+using namespace Scintilla::Internal;
namespace {
@@ -87,10 +91,10 @@ enum class EncodingType { singleByte, utf8, dbcs };
class FontHandle : public Font {
public:
PangoFontDescription *pfd = nullptr;
- int characterSet;
- FontHandle() noexcept : pfd(nullptr), characterSet(-1) {
+ CharacterSet characterSet;
+ FontHandle() noexcept : pfd(nullptr), characterSet(CharacterSet::Ansi) {
}
- FontHandle(PangoFontDescription *pfd_, int characterSet_) noexcept {
+ FontHandle(PangoFontDescription *pfd_, CharacterSet characterSet_) noexcept {
pfd = pfd_;
characterSet = characterSet_;
}
@@ -145,9 +149,9 @@ class SurfaceImpl : public Surface {
PangoContext *pcontext = nullptr;
PangoLayout *layout = nullptr;
Converter conv;
- int characterSet = -1;
+ CharacterSet characterSet = static_cast<CharacterSet>(-1);
void PenColourAlpha(ColourRGBA fore) noexcept;
- void SetConverter(int characterSet_);
+ void SetConverter(CharacterSet characterSet_);
void CairoRectangle(PRectangle rc) noexcept;
public:
SurfaceImpl() noexcept;
@@ -167,7 +171,7 @@ public:
void Clear() noexcept;
void Release() noexcept override;
- int Supports(int feature) noexcept override;
+ int SupportsFeature(Supports feature) noexcept override;
bool Initialised() override;
int LogPixelsY() override;
int PixelDivisions() override;
@@ -216,60 +220,60 @@ public:
void FlushDrawing() override;
};
-const int SupportsGTK[] = {
- SC_SUPPORTS_LINE_DRAWS_FINAL,
- SC_SUPPORTS_FRACTIONAL_STROKE_WIDTH,
- SC_SUPPORTS_TRANSLUCENT_STROKE,
- SC_SUPPORTS_PIXEL_MODIFICATION,
+const Supports SupportsGTK[] = {
+ Supports::LineDrawsFinal,
+ Supports::FractionalStrokeWidth,
+ Supports::TranslucentStroke,
+ Supports::PixelModification,
};
}
-const char *CharacterSetID(int characterSet) noexcept {
+const char *CharacterSetID(CharacterSet characterSet) noexcept {
switch (characterSet) {
- case SC_CHARSET_ANSI:
+ case CharacterSet::Ansi:
return "";
- case SC_CHARSET_DEFAULT:
+ case CharacterSet::Default:
return "ISO-8859-1";
- case SC_CHARSET_BALTIC:
+ case CharacterSet::Baltic:
return "ISO-8859-13";
- case SC_CHARSET_CHINESEBIG5:
+ case CharacterSet::ChineseBig5:
return "BIG-5";
- case SC_CHARSET_EASTEUROPE:
+ case CharacterSet::EastEurope:
return "ISO-8859-2";
- case SC_CHARSET_GB2312:
+ case CharacterSet::GB2312:
return "CP936";
- case SC_CHARSET_GREEK:
+ case CharacterSet::Greek:
return "ISO-8859-7";
- case SC_CHARSET_HANGUL:
+ case CharacterSet::Hangul:
return "CP949";
- case SC_CHARSET_MAC:
+ case CharacterSet::Mac:
return "MACINTOSH";
- case SC_CHARSET_OEM:
+ case CharacterSet::Oem:
return "ASCII";
- case SC_CHARSET_RUSSIAN:
+ case CharacterSet::Russian:
return "KOI8-R";
- case SC_CHARSET_OEM866:
+ case CharacterSet::Oem866:
return "CP866";
- case SC_CHARSET_CYRILLIC:
+ case CharacterSet::Cyrillic:
return "CP1251";
- case SC_CHARSET_SHIFTJIS:
+ case CharacterSet::ShiftJis:
return "SHIFT-JIS";
- case SC_CHARSET_SYMBOL:
+ case CharacterSet::Symbol:
return "";
- case SC_CHARSET_TURKISH:
+ case CharacterSet::Turkish:
return "ISO-8859-9";
- case SC_CHARSET_JOHAB:
+ case CharacterSet::Johab:
return "CP1361";
- case SC_CHARSET_HEBREW:
+ case CharacterSet::Hebrew:
return "ISO-8859-8";
- case SC_CHARSET_ARABIC:
+ case CharacterSet::Arabic:
return "ISO-8859-6";
- case SC_CHARSET_VIETNAMESE:
+ case CharacterSet::Vietnamese:
return "";
- case SC_CHARSET_THAI:
+ case CharacterSet::Thai:
return "ISO-8859-11";
- case SC_CHARSET_8859_15:
+ case CharacterSet::Iso8859_15:
return "ISO-8859-15";
default:
return "";
@@ -286,7 +290,7 @@ void SurfaceImpl::PenColourAlpha(ColourRGBA fore) noexcept {
}
}
-void SurfaceImpl::SetConverter(int characterSet_) {
+void SurfaceImpl::SetConverter(CharacterSet characterSet_) {
if (characterSet != characterSet_) {
characterSet = characterSet_;
conv.Open("UTF-8", CharacterSetID(characterSet), false);
@@ -342,7 +346,7 @@ void SurfaceImpl::Clear() noexcept {
g_object_unref(pcontext);
pcontext = nullptr;
conv.Close();
- characterSet = -1;
+ characterSet = static_cast<CharacterSet>(-1);
inited = false;
createdGC = false;
}
@@ -417,8 +421,8 @@ void SurfaceImpl::SetMode(SurfaceMode mode_) {
}
}
-int SurfaceImpl::Supports(int feature) noexcept {
- for (const int f : SupportsGTK) {
+int SurfaceImpl::SupportsFeature(Supports feature) noexcept {
+ for (const Supports f : SupportsGTK) {
if (f == feature)
return 1;
}
@@ -913,8 +917,8 @@ void SurfaceImpl::MeasureWidths(const Font *font_, std::string_view text, XYPOSI
const size_t lenPositions = text.length();
// Either 8-bit or DBCS conversion failed so treat as 8-bit.
SetConverter(PFont(font_)->characterSet);
- const bool rtlCheck = PFont(font_)->characterSet == SC_CHARSET_HEBREW ||
- PFont(font_)->characterSet == SC_CHARSET_ARABIC;
+ const bool rtlCheck = PFont(font_)->characterSet == CharacterSet::Hebrew ||
+ PFont(font_)->characterSet == CharacterSet::Arabic;
std::string utfForm = UTF8FromIconv(conv, text);
if (utfForm.empty()) {
utfForm = UTF8FromLatin1(text);
@@ -1120,7 +1124,7 @@ void SurfaceImpl::FlushCachedState() {}
void SurfaceImpl::FlushDrawing() {
}
-std::unique_ptr<Surface> Surface::Allocate(int) {
+std::unique_ptr<Surface> Surface::Allocate(Technology) {
return std::make_unique<SurfaceImpl>();
}
@@ -1385,7 +1389,7 @@ public:
#endif
}
void SetFont(const Font *font) override;
- void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_) override;
+ void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, Technology technology_) override;
void SetAverageCharWidth(int width) override;
void SetVisibleRows(int rows) override;
int GetVisibleRows() const override;
@@ -1570,7 +1574,7 @@ static void StyleSet(GtkWidget *w, GtkStyle *, void *) {
#endif
}
-void ListBoxX::Create(Window &parent, int, Point, int, bool, int) {
+void ListBoxX::Create(Window &parent, int, Point, int, bool, Technology) {
if (widCached != nullptr) {
wid = widCached;
return;
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 7f7521423..e80081712 100755
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -38,12 +38,16 @@
#include <windows.h>
#endif
+#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 "ScintillaWidget.h"
#include "CharacterCategoryMap.h"
@@ -90,6 +94,7 @@
#define SC_INDICATOR_UNKNOWN INDICATOR_IME_MAX
using namespace Scintilla;
+using namespace Scintilla::Internal;
// From PlatGTK.cxx
extern std::string UTF8FromLatin1(std::string_view text);
@@ -363,7 +368,7 @@ void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
Finalise();
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -385,7 +390,7 @@ void ScintillaGTK::MapThis() {
ChangeSize();
gdk_window_show(PWindow(wMain));
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -406,7 +411,7 @@ void ScintillaGTK::UnMapThis() {
if (PWidget(scrollbarv))
gtk_widget_unmap(PWidget(scrollbarv));
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -423,7 +428,7 @@ void ScintillaGTK::ForAll(GtkCallback callback, gpointer callback_data) {
if (PWidget(scrollbarh))
(*callback)(PWidget(scrollbarh), callback_data);
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -489,7 +494,7 @@ gint ScintillaGTK::FocusInThis(GtkWidget *) {
}
}
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
}
@@ -509,7 +514,7 @@ gint ScintillaGTK::FocusOutThis(GtkWidget *) {
gtk_im_context_focus_out(im_context);
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
}
@@ -563,7 +568,7 @@ void ScintillaGTK::SizeAllocate(GtkWidget *widget, GtkAllocation *allocation) {
sciThis->Resize(allocation->width, allocation->height);
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -686,10 +691,10 @@ void ScintillaGTK::Init() {
timers[tr].reason = static_cast<TickReason>(tr);
timers[tr].scintilla = this;
}
- vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(INDIC_HIDDEN, ColourRGBA(0, 0, 0xff));
- vs.indicators[SC_INDICATOR_INPUT] = Indicator(INDIC_DOTS, ColourRGBA(0, 0, 0xff));
- vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(INDIC_COMPOSITIONTHICK, ColourRGBA(0, 0, 0xff));
- vs.indicators[SC_INDICATOR_TARGET] = Indicator(INDIC_STRAIGHTBOX, ColourRGBA(0, 0, 0xff));
+ vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(IndicatorStyle::Hidden, ColourRGBA(0, 0, 0xff));
+ vs.indicators[SC_INDICATOR_INPUT] = Indicator(IndicatorStyle::Dots, ColourRGBA(0, 0, 0xff));
+ vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(IndicatorStyle::CompositionThick, ColourRGBA(0, 0, 0xff));
+ vs.indicators[SC_INDICATOR_TARGET] = Indicator(IndicatorStyle::StraightBox, ColourRGBA(0, 0, 0xff));
fontOptionsPrevious = FontOptions(PWidget(wText));
}
@@ -715,7 +720,7 @@ bool ScintillaGTK::AbandonPaint() {
}
void ScintillaGTK::DisplayCursor(Window::Cursor c) {
- if (cursorMode == SC_CURSORNORMAL)
+ if (cursorMode == CursorShape::Normal)
wText.SetCursor(c);
else
wText.SetCursor(static_cast<Window::Cursor>(cursorMode));
@@ -867,35 +872,35 @@ std::string ScintillaGTK::EncodedFromUTF8(std::string_view utf8) const {
}
}
-sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+sptr_t ScintillaGTK::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
try {
switch (iMessage) {
- case SCI_GRABFOCUS:
+ case Message::GrabFocus:
gtk_widget_grab_focus(PWidget(wMain));
break;
- case SCI_GETDIRECTFUNCTION:
+ case Message::GetDirectFunction:
return reinterpret_cast<sptr_t>(DirectFunction);
- case SCI_GETDIRECTPOINTER:
+ case Message::GetDirectPointer:
return reinterpret_cast<sptr_t>(this);
- case SCI_TARGETASUTF8:
+ case Message::TargetAsUTF8:
return TargetAsUTF8(CharPtrFromSPtr(lParam));
- case SCI_ENCODEDFROMUTF8:
+ case Message::EncodedFromUTF8:
return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam),
CharPtrFromSPtr(lParam));
- case SCI_SETRECTANGULARSELECTIONMODIFIER:
+ case Message::SetRectangularSelectionModifier:
rectangularSelectionModifier = static_cast<int>(wParam);
break;
- case SCI_GETRECTANGULARSELECTIONMODIFIER:
+ case Message::GetRectangularSelectionModifier:
return rectangularSelectionModifier;
- case SCI_SETREADONLY: {
+ case Message::SetReadOnly: {
const sptr_t ret = ScintillaBase::WndProc(iMessage, wParam, lParam);
if (accessible) {
ScintillaGTKAccessible *sciAccessible = ScintillaGTKAccessible::FromAccessible(accessible);
@@ -906,10 +911,10 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return ret;
}
- case SCI_GETACCESSIBILITY:
+ case Message::GetAccessibility:
return accessibilityEnabled;
- case SCI_SETACCESSIBILITY:
+ case Message::SetAccessibility:
accessibilityEnabled = static_cast<int>(wParam);
if (accessible) {
ScintillaGTKAccessible *sciAccessible = ScintillaGTKAccessible::FromAccessible(accessible);
@@ -923,14 +928,14 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return ScintillaBase::WndProc(iMessage, wParam, lParam);
}
} catch (std::bad_alloc &) {
- errorStatus = SC_STATUS_BADALLOC;
+ errorStatus = Status::BadAlloc;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return 0;
}
-sptr_t ScintillaGTK::DefWndProc(unsigned int, uptr_t, sptr_t) {
+sptr_t ScintillaGTK::DefWndProc(Message, uptr_t, sptr_t) {
return 0;
}
@@ -1145,31 +1150,31 @@ void ScintillaGTK::NotifyFocus(bool focus) {
Editor::NotifyFocus(focus);
}
-void ScintillaGTK::NotifyParent(SCNotification scn) {
+void ScintillaGTK::NotifyParent(NotificationData scn) {
scn.nmhdr.hwndFrom = PWidget(wMain);
scn.nmhdr.idFrom = GetCtrlID();
g_signal_emit(G_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL], 0,
GetCtrlID(), &scn);
}
-void ScintillaGTK::NotifyKey(int key, int modifiers) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_KEY;
- scn.ch = key;
+void ScintillaGTK::NotifyKey(Keys key, KeyMod modifiers) {
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::Key;
+ scn.ch = static_cast<int>(key);
scn.modifiers = modifiers;
NotifyParent(scn);
}
void ScintillaGTK::NotifyURIDropped(const char *list) {
- SCNotification scn = {};
- scn.nmhdr.code = SCN_URIDROPPED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::URIDropped;
scn.text = list;
NotifyParent(scn);
}
-const char *CharacterSetID(int characterSet);
+const char *CharacterSetID(CharacterSet characterSet);
const char *ScintillaGTK::CharacterSetID() const {
return ::CharacterSetID(vs.styles[STYLE_DEFAULT].characterSet);
@@ -1293,7 +1298,7 @@ std::string ScintillaGTK::CaseMapString(const std::string &s, CaseMapping caseMa
}
}
-int ScintillaGTK::KeyDefault(int key, int modifiers) {
+int ScintillaGTK::KeyDefault(Keys key, KeyMod modifiers) {
// Pass up to container in case it is an accelerator
NotifyKey(key, modifiers);
return 0;
@@ -1430,7 +1435,7 @@ void ScintillaGTK::PrimaryGetSelectionThis(GtkClipboard *clip, GtkSelectionData
GetSelection(selection_data, info, &primary);
}
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -1448,7 +1453,7 @@ void ScintillaGTK::PrimaryClearSelectionThis(GtkClipboard *clip) {
Redraw();
}
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -1510,7 +1515,7 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio
if (IsUnicodeMode()) {
// Unknown encoding so assume in Latin1
dest = UTF8FromLatin1(dest);
- selText.Copy(dest, SC_CP_UTF8, 0, isRectangular, false);
+ selText.Copy(dest, CpUtf8, CharacterSet::Ansi, isRectangular, false);
} else {
// Assume buffer is in same encoding as selection
selText.Copy(dest, pdoc->dbcsCodePage,
@@ -1524,7 +1529,7 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio
selText.Copy(dest, pdoc->dbcsCodePage,
vs.styles[STYLE_DEFAULT].characterSet, isRectangular, false);
} else {
- selText.Copy(dest, SC_CP_UTF8, 0, isRectangular, false);
+ selText.Copy(dest, CpUtf8, CharacterSet::Ansi, isRectangular, false);
}
}
}
@@ -1538,7 +1543,7 @@ void ScintillaGTK::InsertSelection(GtkClipboard *clipBoard, GtkSelectionData *se
UndoGroup ug(pdoc);
if (selection == GDK_SELECTION_CLIPBOARD) {
- ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH);
+ ClearSelection(multiPasteMode == MultiPaste::Each);
}
InsertPasteShape(selText.Data(), selText.Length(),
@@ -1565,7 +1570,7 @@ void ScintillaGTK::ReceivedClipboard(GtkClipboard *clipBoard, GtkSelectionData *
try {
InsertSelection(clipBoard, selection_data);
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -1585,7 +1590,7 @@ void ScintillaGTK::ReceivedSelection(GtkSelectionData *selection_data) {
// else fprintf(stderr, "Target non string %d %d\n", (int)(selection_data->type),
// (int)(atomUTF8));
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -1617,9 +1622,9 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
// from code below
std::unique_ptr<SelectionText> newline_normalized;
{
- std::string tmpstr = Document::TransformLineEnds(text->Data(), text->Length(), SC_EOL_LF);
+ std::string tmpstr = Document::TransformLineEnds(text->Data(), text->Length(), EndOfLine::Lf);
newline_normalized.reset(new SelectionText());
- newline_normalized->Copy(tmpstr, SC_CP_UTF8, 0, text->rectangular, false);
+ newline_normalized->Copy(tmpstr, CpUtf8, CharacterSet::Ansi, text->rectangular, false);
text = newline_normalized.get();
}
#endif
@@ -1631,7 +1636,7 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
if (*charSet) {
std::string tmputf = ConvertText(text->Data(), text->Length(), "UTF-8", charSet, false);
converted = std::make_unique<SelectionText>();
- converted->Copy(tmputf, SC_CP_UTF8, 0, text->rectangular, false);
+ converted->Copy(tmputf, CpUtf8, CharacterSet::Ansi, text->rectangular, false);
text = converted.get();
}
}
@@ -1692,7 +1697,7 @@ void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) {
}
}
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -1888,7 +1893,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) {
SetAdjustmentValue(adjustmentv, static_cast<int>(topLine) + 3);
}
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return TRUE;
}
@@ -1914,14 +1919,14 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) {
// If mouse released on scroll bar then the position is relative to the
// scrollbar, not the drawing window so just repeat the most recent point.
pt = sciThis->ptMouseLast;
- const int modifiers = ModifierFlags(
+ const KeyMod modifiers = ModifierFlags(
(event->state & GDK_SHIFT_MASK) != 0,
(event->state & GDK_CONTROL_MASK) != 0,
(event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0);
sciThis->ButtonUpWithModifiers(pt, event->time, modifiers);
}
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2010,9 +2015,9 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) {
// Text font size zoom
} else if (event->state & GDK_CONTROL_MASK) {
if (cLineScroll < 0) {
- sciThis->KeyCommand(SCI_ZOOMIN);
+ sciThis->KeyCommand(Message::ZoomIn);
} else {
- sciThis->KeyCommand(SCI_ZOOMOUT);
+ sciThis->KeyCommand(Message::ZoomOut);
}
// Regular scrolling
@@ -2021,7 +2026,7 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) {
}
return TRUE;
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2050,13 +2055,13 @@ gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) {
//Platform::DebugPrintf("Move %x %x %d %c %d %d\n",
// sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y);
const Point pt(static_cast<XYPOSITION>(x), static_cast<XYPOSITION>(y));
- const int modifiers = ModifierFlags(
+ const KeyMod modifiers = ModifierFlags(
(event->state & GDK_SHIFT_MASK) != 0,
(event->state & GDK_CONTROL_MASK) != 0,
(event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0);
sciThis->ButtonMoveWithModifiers(pt, event->time, modifiers);
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2244,7 +2249,7 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) {
const bool meta = ctrl;
ctrl = (event->state & GDK_META_MASK) != 0;
#endif
- const bool added = KeyDownWithModifiers(key, ModifierFlags(shift, ctrl, alt, meta, super), &consumed) != 0;
+ const bool added = KeyDownWithModifiers(static_cast<Keys>(key), ModifierFlags(shift, ctrl, alt, meta, super), &consumed) != 0;
if (!consumed)
consumed = added;
//fprintf(stderr, "SK-key: %d %x %x\n",event->keyval, event->state, consumed);
@@ -2257,7 +2262,7 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) {
}
return consumed;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2289,7 +2294,7 @@ gboolean ScintillaGTK::DrawPreeditThis(GtkWidget *, cairo_t *cr) {
g_object_unref(layout);
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return TRUE;
}
@@ -2312,7 +2317,7 @@ gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *) {
cairo_destroy(context);
g_object_unref(layout);
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return TRUE;
}
@@ -2442,12 +2447,12 @@ void ScintillaGTK::CommitThis(char *commitStr) {
if (!IsUnicodeMode())
docChar = ConvertText(u8Char, u8CharLen, charSetSource, "UTF-8", true);
- InsertCharacter(docChar, CharacterSource::directInput);
+ InsertCharacter(docChar, CharacterSource::DirectInput);
}
g_free(uniStr);
ShowCaretAtCurrentPosition();
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -2504,7 +2509,7 @@ void ScintillaGTK::PreeditChangedInlineThis() {
if (!IsUnicodeMode())
docChar = ConvertText(u8Char, u8CharLen, charSetSource, "UTF-8", true);
- InsertCharacter(docChar, CharacterSource::tentativeInput);
+ InsertCharacter(docChar, CharacterSource::TentativeInput);
DrawImeIndicator(indicator[i], docChar.size());
}
@@ -2528,7 +2533,7 @@ void ScintillaGTK::PreeditChangedInlineThis() {
EnsureCaretVisible();
ShowCaretAtCurrentPosition();
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
@@ -2562,12 +2567,12 @@ void ScintillaGTK::PreeditChangedWindowedThis() {
gtk_widget_hide(PWidget(wPreedit));
}
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
}
void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) {
- if ((sciThis->imeInteraction == IMEInteraction::internal) || (sciThis->KoreanIME())) {
+ if ((sciThis->imeInteraction == IMEInteraction::Inline) || (sciThis->KoreanIME())) {
sciThis->PreeditChangedInlineThis();
} else {
sciThis->PreeditChangedWindowedThis();
@@ -2670,7 +2675,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) {
rcPaint.bottom = y2;
PRectangle rcClient = GetClientRectangle();
paintingAllText = rcPaint.Contains(rcClient);
- std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(Technology::Default));
surfaceWindow->Init(cr, PWidget(wText));
Paint(surfaceWindow.get(), rcPaint);
surfaceWindow->Release();
@@ -2687,7 +2692,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) {
rgnUpdate = 0;
paintState = PaintState::notPainting;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
@@ -2732,7 +2737,7 @@ gboolean ScintillaGTK::DrawThis(cairo_t *cr) {
}
#endif
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2760,7 +2765,7 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os
rgnUpdate = gdk_region_copy(ose->region);
const PRectangle rcClient = GetClientRectangle();
paintingAllText = rcPaint.Contains(rcClient);
- std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(Technology::Default));
cairo_t *cr = gdk_cairo_create(PWindow(wText));
surfaceWindow->Init(cr, PWidget(wText));
Paint(surfaceWindow.get(), rcPaint);
@@ -2778,7 +2783,7 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os
}
rgnUpdate = nullptr;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
@@ -2807,7 +2812,7 @@ gboolean ScintillaGTK::Expose(GtkWidget *, GdkEventExpose *ose) {
GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarv), ose);
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2818,7 +2823,7 @@ void ScintillaGTK::ScrollSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) {
try {
sciThis->ScrollTo(static_cast<int>(gtk_adjustment_get_value(adj)), false);
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -2826,7 +2831,7 @@ void ScintillaGTK::ScrollHSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) {
try {
sciThis->HorizontalScrollTo(static_cast<int>(gtk_adjustment_get_value(adj)));
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -2849,7 +2854,7 @@ void ScintillaGTK::SelectionGet(GtkWidget *widget,
sciThis->GetSelection(selection_data, info, &sciThis->primary);
}
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -2880,7 +2885,7 @@ gboolean ScintillaGTK::DragMotionThis(GdkDragContext *context,
}
gdk_drag_status(context, preferredAction, dragtime);
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2897,7 +2902,7 @@ void ScintillaGTK::DragLeave(GtkWidget *widget, GdkDragContext * /*context*/, gu
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
//Platform::DebugPrintf("DragLeave %x\n", sciThis);
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -2911,7 +2916,7 @@ void ScintillaGTK::DragEnd(GtkWidget *widget, GdkDragContext * /*context*/) {
//Platform::DebugPrintf("DragEnd %x %d\n", sciThis, sciThis->dragWasDropped);
sciThis->inDragDrop = DragDrop::none;
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -2922,7 +2927,7 @@ gboolean ScintillaGTK::Drop(GtkWidget *widget, GdkDragContext * /*context*/,
//Platform::DebugPrintf("Drop %x\n", sciThis);
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
return FALSE;
}
@@ -2934,7 +2939,7 @@ void ScintillaGTK::DragDataReceived(GtkWidget *widget, GdkDragContext * /*contex
sciThis->ReceivedDrop(selection_data);
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -2961,7 +2966,7 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
}
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
}
@@ -3069,7 +3074,7 @@ gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) {
gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) {
try {
- std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(Technology::Default));
cairo_t *cr = gdk_cairo_create(WindowFromWidget(widget));
surfaceWindow->Init(cr, widget);
surfaceWindow->SetMode(SurfaceMode(ctip->codePage, false));
@@ -3094,13 +3099,13 @@ AtkObject *ScintillaGTK::GetAccessible(GtkWidget *widget) {
sptr_t ScintillaGTK::DirectFunction(
sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
- return reinterpret_cast<ScintillaGTK *>(ptr)->WndProc(iMessage, wParam, lParam);
+ return reinterpret_cast<ScintillaGTK *>(ptr)->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
/* legacy name for scintilla_object_send_message */
sptr_t scintilla_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
ScintillaGTK *psci = static_cast<ScintillaGTK *>(sci->pscin);
- return psci->WndProc(iMessage, wParam, lParam);
+ return psci->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
gintptr scintilla_object_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h
index 5461ff37b..715e7ed50 100755
--- a/gtk/ScintillaGTK.h
+++ b/gtk/ScintillaGTK.h
@@ -6,7 +6,7 @@
#ifndef SCINTILLAGTK_H
#define SCINTILLAGTK_H
-namespace Scintilla {
+namespace Scintilla::Internal {
class ScintillaGTKAccessible;
@@ -105,9 +105,9 @@ private:
std::string UTF8FromEncoded(std::string_view encoded) const override;
std::string EncodedFromUTF8(std::string_view utf8) const override;
public: // Public for scintilla_send_message
- sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t WndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) override;
private:
- sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t DefWndProc(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) override;
struct TimeThunk {
TickReason reason;
ScintillaGTK *scintilla;
@@ -131,13 +131,13 @@ private:
void ReconfigureScrollBars() override;
void NotifyChange() override;
void NotifyFocus(bool focus) override;
- void NotifyParent(SCNotification scn) override;
- void NotifyKey(int key, int modifiers);
+ void NotifyParent(Scintilla::NotificationData scn) override;
+ void NotifyKey(Scintilla::Keys key, Scintilla::KeyMod modifiers);
void NotifyURIDropped(const char *list);
const char *CharacterSetID() const;
std::unique_ptr<CaseFolder> CaseFolderForEncoding() override;
std::string CaseMapString(const std::string &s, CaseMapping caseMapping) override;
- int KeyDefault(int key, int modifiers) override;
+ int KeyDefault(Scintilla::Keys key, Scintilla::KeyMod modifiers) override;
void CopyToClipboard(const SelectionText &selectedText) override;
void Copy() override;
void RequestSelection(GdkAtom atomSelection);
diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx
index 25490277b..bff9a4572 100644
--- a/gtk/ScintillaGTKAccessible.cxx
+++ b/gtk/ScintillaGTKAccessible.cxx
@@ -89,12 +89,16 @@
#endif
// ScintillaGTK.h and stuff it needs
+#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 "ScintillaWidget.h"
#include "CharacterCategoryMap.h"
@@ -130,6 +134,7 @@
#include "ScintillaGTKAccessible.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
struct ScintillaObjectAccessiblePrivate {
ScintillaGTKAccessible *pscin;
@@ -223,30 +228,30 @@ gchar *ScintillaGTKAccessible::GetTextAfterOffset(int charOffset,
break;
case ATK_TEXT_BOUNDARY_WORD_START:
- startByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1);
- startByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 0);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 1);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 0);
+ startByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1);
+ startByte = sci->WndProc(Message::WordEndPosition, startByte, 0);
+ endByte = sci->WndProc(Message::WordEndPosition, startByte, 1);
+ endByte = sci->WndProc(Message::WordEndPosition, endByte, 0);
break;
case ATK_TEXT_BOUNDARY_WORD_END:
- startByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 0);
- startByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 1);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, startByte, 0);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 1);
+ startByte = sci->WndProc(Message::WordEndPosition, byteOffset, 0);
+ startByte = sci->WndProc(Message::WordEndPosition, startByte, 1);
+ endByte = sci->WndProc(Message::WordEndPosition, startByte, 0);
+ endByte = sci->WndProc(Message::WordEndPosition, endByte, 1);
break;
case ATK_TEXT_BOUNDARY_LINE_START: {
- int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
- startByte = sci->WndProc(SCI_POSITIONFROMLINE, line + 1, 0);
- endByte = sci->WndProc(SCI_POSITIONFROMLINE, line + 2, 0);
+ int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
+ startByte = sci->WndProc(Message::PositionFromLine, line + 1, 0);
+ endByte = sci->WndProc(Message::PositionFromLine, line + 2, 0);
break;
}
case ATK_TEXT_BOUNDARY_LINE_END: {
- int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
- startByte = sci->WndProc(SCI_GETLINEENDPOSITION, line, 0);
- endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line + 1, 0);
+ int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
+ startByte = sci->WndProc(Message::GetLineEndPosition, line, 0);
+ endByte = sci->WndProc(Message::GetLineEndPosition, line + 1, 0);
break;
}
@@ -273,24 +278,24 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset,
break;
case ATK_TEXT_BOUNDARY_WORD_START:
- endByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 0);
- endByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 1);
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 0);
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 1);
+ endByte = sci->WndProc(Message::WordStartPosition, byteOffset, 0);
+ endByte = sci->WndProc(Message::WordStartPosition, endByte, 1);
+ startByte = sci->WndProc(Message::WordStartPosition, endByte, 0);
+ startByte = sci->WndProc(Message::WordStartPosition, startByte, 1);
break;
case ATK_TEXT_BOUNDARY_WORD_END:
- endByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1);
- endByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 0);
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, endByte, 1);
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 0);
+ endByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1);
+ endByte = sci->WndProc(Message::WordStartPosition, endByte, 0);
+ startByte = sci->WndProc(Message::WordStartPosition, endByte, 1);
+ startByte = sci->WndProc(Message::WordStartPosition, startByte, 0);
break;
case ATK_TEXT_BOUNDARY_LINE_START: {
- int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
- endByte = sci->WndProc(SCI_POSITIONFROMLINE, line, 0);
+ int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
+ endByte = sci->WndProc(Message::PositionFromLine, line, 0);
if (line > 0) {
- startByte = sci->WndProc(SCI_POSITIONFROMLINE, line - 1, 0);
+ startByte = sci->WndProc(Message::PositionFromLine, line - 1, 0);
} else {
startByte = endByte;
}
@@ -298,14 +303,14 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset,
}
case ATK_TEXT_BOUNDARY_LINE_END: {
- int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
+ int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
if (line > 0) {
- endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line - 1, 0);
+ endByte = sci->WndProc(Message::GetLineEndPosition, line - 1, 0);
} else {
endByte = 0;
}
if (line > 1) {
- startByte = sci->WndProc(SCI_GETLINEENDPOSITION, line - 2, 0);
+ startByte = sci->WndProc(Message::GetLineEndPosition, line - 2, 0);
} else {
startByte = endByte;
}
@@ -331,46 +336,46 @@ gchar *ScintillaGTKAccessible::GetTextAtOffset(int charOffset,
switch (boundaryType) {
case ATK_TEXT_BOUNDARY_CHAR:
startByte = byteOffset;
- endByte = sci->WndProc(SCI_POSITIONAFTER, byteOffset, 0);
+ endByte = sci->WndProc(Message::PositionAfter, byteOffset, 0);
break;
case ATK_TEXT_BOUNDARY_WORD_START:
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1);
- if (! sci->WndProc(SCI_ISRANGEWORD, startByte, endByte)) {
+ startByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1);
+ endByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1);
+ if (! sci->WndProc(Message::IsRangeWord, startByte, endByte)) {
// if the cursor was not on a word, forward back
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 0);
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 1);
+ startByte = sci->WndProc(Message::WordStartPosition, startByte, 0);
+ startByte = sci->WndProc(Message::WordStartPosition, startByte, 1);
}
- endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 0);
+ endByte = sci->WndProc(Message::WordEndPosition, endByte, 0);
break;
case ATK_TEXT_BOUNDARY_WORD_END:
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1);
- if (! sci->WndProc(SCI_ISRANGEWORD, startByte, endByte)) {
+ startByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1);
+ endByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1);
+ if (! sci->WndProc(Message::IsRangeWord, startByte, endByte)) {
// if the cursor was not on a word, forward back
- endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 0);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, endByte, 1);
+ endByte = sci->WndProc(Message::WordEndPosition, endByte, 0);
+ endByte = sci->WndProc(Message::WordEndPosition, endByte, 1);
}
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, startByte, 0);
+ startByte = sci->WndProc(Message::WordStartPosition, startByte, 0);
break;
case ATK_TEXT_BOUNDARY_LINE_START: {
- int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
- startByte = sci->WndProc(SCI_POSITIONFROMLINE, line, 0);
- endByte = sci->WndProc(SCI_POSITIONFROMLINE, line + 1, 0);
+ int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
+ startByte = sci->WndProc(Message::PositionFromLine, line, 0);
+ endByte = sci->WndProc(Message::PositionFromLine, line + 1, 0);
break;
}
case ATK_TEXT_BOUNDARY_LINE_END: {
- int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
+ int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
if (line > 0) {
- startByte = sci->WndProc(SCI_GETLINEENDPOSITION, line - 1, 0);
+ startByte = sci->WndProc(Message::GetLineEndPosition, line - 1, 0);
} else {
startByte = 0;
}
- endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line, 0);
+ endByte = sci->WndProc(Message::GetLineEndPosition, line, 0);
break;
}
@@ -394,16 +399,16 @@ gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset,
switch (granularity) {
case ATK_TEXT_GRANULARITY_CHAR:
startByte = byteOffset;
- endByte = sci->WndProc(SCI_POSITIONAFTER, byteOffset, 0);
+ endByte = sci->WndProc(Message::PositionAfter, byteOffset, 0);
break;
case ATK_TEXT_GRANULARITY_WORD:
- startByte = sci->WndProc(SCI_WORDSTARTPOSITION, byteOffset, 1);
- endByte = sci->WndProc(SCI_WORDENDPOSITION, byteOffset, 1);
+ startByte = sci->WndProc(Message::WordStartPosition, byteOffset, 1);
+ endByte = sci->WndProc(Message::WordEndPosition, byteOffset, 1);
break;
case ATK_TEXT_GRANULARITY_LINE: {
- gint line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
- startByte = sci->WndProc(SCI_POSITIONFROMLINE, line, 0);
- endByte = sci->WndProc(SCI_GETLINEENDPOSITION, line, 0);
+ gint line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
+ startByte = sci->WndProc(Message::PositionFromLine, line, 0);
+ endByte = sci->WndProc(Message::GetLineEndPosition, line, 0);
break;
}
default:
@@ -433,11 +438,11 @@ gint ScintillaGTKAccessible::GetCharacterCount() {
}
gint ScintillaGTKAccessible::GetCaretOffset() {
- return CharacterOffsetFromByteOffset(sci->WndProc(SCI_GETCURRENTPOS, 0, 0));
+ return CharacterOffsetFromByteOffset(sci->WndProc(Message::GetCurrentPos, 0, 0));
}
gboolean ScintillaGTKAccessible::SetCaretOffset(int charOffset) {
- sci->WndProc(SCI_GOTOPOS, ByteOffsetFromCharacterOffset(charOffset), 0);
+ sci->WndProc(Message::GotoPos, ByteOffsetFromCharacterOffset(charOffset), 0);
return TRUE;
}
@@ -461,7 +466,7 @@ gint ScintillaGTKAccessible::GetOffsetAtPoint(gint x, gint y, AtkCoordType coord
}
// FIXME: should we handle scrolling?
- return CharacterOffsetFromByteOffset(sci->WndProc(SCI_CHARPOSITIONFROMPOINTCLOSE, x, y));
+ return CharacterOffsetFromByteOffset(sci->WndProc(Message::CharPositionFromPointClose, x, y));
}
void ScintillaGTKAccessible::GetCharacterExtents(int charOffset,
@@ -471,14 +476,14 @@ void ScintillaGTKAccessible::GetCharacterExtents(int charOffset,
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
// FIXME: should we handle scrolling?
- *x = sci->WndProc(SCI_POINTXFROMPOSITION, 0, byteOffset);
- *y = sci->WndProc(SCI_POINTYFROMPOSITION, 0, byteOffset);
+ *x = sci->WndProc(Message::PointXFromPosition, 0, byteOffset);
+ *y = sci->WndProc(Message::PointYFromPosition, 0, byteOffset);
- int line = sci->WndProc(SCI_LINEFROMPOSITION, byteOffset, 0);
- *height = sci->WndProc(SCI_TEXTHEIGHT, line, 0);
+ int line = sci->WndProc(Message::LineFromPosition, byteOffset, 0);
+ *height = sci->WndProc(Message::TextHeight, line, 0);
int nextByteOffset = PositionAfter(byteOffset);
- int next_x = sci->WndProc(SCI_POINTXFROMPOSITION, 0, nextByteOffset);
+ int next_x = sci->WndProc(Message::PointXFromPosition, 0, nextByteOffset);
if (next_x > *x) {
*width = next_x - *x;
} else if (nextByteOffset > byteOffset) {
@@ -538,7 +543,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetAttributesForStyle(unsigned int styl
attr_set = AddTextAttribute(attr_set, ATK_TEXT_ATTR_FAMILY_NAME, g_strdup(style.fontName));
attr_set = AddTextAttribute(attr_set, ATK_TEXT_ATTR_SIZE, g_strdup_printf("%d", style.size / SC_FONT_SIZE_MULTIPLIER));
- attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_WEIGHT, CLAMP(style.weight, 100, 1000));
+ attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_WEIGHT, CLAMP(static_cast<int>(style.weight), 100, 1000));
attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_STYLE, style.italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
attr_set = AddTextIntAttribute(attr_set, ATK_TEXT_ATTR_UNDERLINE, style.underline ? PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE);
attr_set = AddTextColorAttribute(attr_set, ATK_TEXT_ATTR_FG_COLOR, style.fore);
@@ -554,7 +559,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *s
Sci::Position byteOffset;
if (charOffset == -1) {
- byteOffset = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
+ byteOffset = sci->WndProc(Message::GetCurrentPos, 0, 0);
} else {
byteOffset = ByteOffsetFromCharacterOffset(charOffset);
}
@@ -601,9 +606,9 @@ gboolean ScintillaGTKAccessible::AddSelection(int startChar, int endChar) {
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
// use WndProc() to set the selections so it notifies as needed
if (n_selections > 1 || ! sci->sel.Empty()) {
- sci->WndProc(SCI_ADDSELECTION, startByte, endByte);
+ sci->WndProc(Message::AddSelection, startByte, endByte);
} else {
- sci->WndProc(SCI_SETSELECTION, startByte, endByte);
+ sci->WndProc(Message::SetSelection, startByte, endByte);
}
return TRUE;
@@ -615,11 +620,11 @@ gboolean ScintillaGTKAccessible::RemoveSelection(gint selection_num) {
return FALSE;
if (n_selections > 1) {
- sci->WndProc(SCI_DROPSELECTIONN, selection_num, 0);
+ sci->WndProc(Message::DropSelectionN, selection_num, 0);
} else if (sci->sel.Empty()) {
return FALSE;
} else {
- sci->WndProc(SCI_CLEARSELECTIONS, 0, 0);
+ sci->WndProc(Message::ClearSelections, 0, 0);
}
return TRUE;
@@ -632,8 +637,8 @@ gboolean ScintillaGTKAccessible::SetSelection(gint selection_num, int startChar,
Sci::Position startByte, endByte;
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
- sci->WndProc(SCI_SETSELECTIONNSTART, selection_num, startByte);
- sci->WndProc(SCI_SETSELECTIONNEND, selection_num, endByte);
+ sci->WndProc(Message::SetSelectionNStart, selection_num, startByte);
+ sci->WndProc(Message::SetSelectionNEnd, selection_num, endByte);
return TRUE;
}
@@ -666,7 +671,7 @@ void ScintillaGTKAccessible::AtkTextIface::init(::AtkTextIface *iface) {
void ScintillaGTKAccessible::SetTextContents(const gchar *contents) {
// FIXME: it's probably useless to check for READONLY here, SETTEXT probably does it just fine?
if (! sci->pdoc->IsReadOnly()) {
- sci->WndProc(SCI_SETTEXT, 0, (sptr_t) contents);
+ sci->WndProc(Message::SetText, 0, (sptr_t) contents);
}
}
@@ -797,7 +802,7 @@ bool ScintillaGTKAccessible::Enabled() const {
// Callbacks
void ScintillaGTKAccessible::UpdateCursor() {
- Sci::Position pos = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
+ Sci::Position pos = sci->WndProc(Message::GetCurrentPos, 0, 0);
if (old_pos != pos) {
int charPosition = CharacterOffsetFromByteOffset(pos);
g_signal_emit_by_name(accessible, "text-caret-moved", charPosition);
@@ -867,39 +872,41 @@ void ScintillaGTKAccessible::NotifyReadOnly() {
void ScintillaGTKAccessible::SetAccessibility(bool enabled) {
// Called by ScintillaGTK when application has enabled or disabled accessibility
if (enabled)
- sci->pdoc->AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF32);
+ sci->pdoc->AllocateLineCharacterIndex(LineCharacterIndexType::Utf32);
else
- sci->pdoc->ReleaseLineCharacterIndex(SC_LINECHARACTERINDEX_UTF32);
+ sci->pdoc->ReleaseLineCharacterIndex(LineCharacterIndexType::Utf32);
}
-void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) {
+void ScintillaGTKAccessible::Notify(GtkWidget *, gint, NotificationData *nt) {
if (!Enabled())
return;
switch (nt->nmhdr.code) {
- case SCN_MODIFIED: {
- if (nt->modificationType & SC_MOD_INSERTTEXT) {
+ case Notification::Modified: {
+ if (FlagSet(nt->modificationType, ModificationFlags::InsertText)) {
int startChar = CharacterOffsetFromByteOffset(nt->position);
int lengthChar = sci->pdoc->CountCharacters(nt->position, nt->position + nt->length);
g_signal_emit_by_name(accessible, "text-changed::insert", startChar, lengthChar);
UpdateCursor();
}
- if (nt->modificationType & SC_MOD_BEFOREDELETE) {
+ if (FlagSet(nt->modificationType, ModificationFlags::BeforeDelete)) {
int startChar = CharacterOffsetFromByteOffset(nt->position);
int lengthChar = sci->pdoc->CountCharacters(nt->position, nt->position + nt->length);
g_signal_emit_by_name(accessible, "text-changed::delete", startChar, lengthChar);
}
- if (nt->modificationType & SC_MOD_DELETETEXT) {
+ if (FlagSet(nt->modificationType, ModificationFlags::DeleteText)) {
UpdateCursor();
}
- if (nt->modificationType & SC_MOD_CHANGESTYLE) {
+ if (FlagSet(nt->modificationType, ModificationFlags::ChangeStyle)) {
g_signal_emit_by_name(accessible, "text-attributes-changed");
}
} break;
- case SCN_UPDATEUI: {
- if (nt->updated & SC_UPDATE_SELECTION) {
+ case Notification::UpdateUI: {
+ if (FlagSet(nt->updated, Update::Selection)) {
UpdateCursor();
}
} break;
+ default:
+ break;
}
}
@@ -1145,7 +1152,7 @@ static AtkStateSet *scintilla_object_accessible_ref_state_set(AtkObject *accessi
if (widget == nullptr) {
atk_state_set_add_state(state_set, ATK_STATE_DEFUNCT);
} else {
- if (! scintilla_send_message(SCINTILLA_OBJECT(widget), SCI_GETREADONLY, 0, 0))
+ if (! scintilla_send_message(SCINTILLA_OBJECT(widget), static_cast<int>(Message::GetReadOnly), 0, 0))
atk_state_set_add_state(state_set, ATK_STATE_EDITABLE);
#if ATK_CHECK_VERSION(2, 16, 0)
else
diff --git a/gtk/ScintillaGTKAccessible.h b/gtk/ScintillaGTKAccessible.h
index 2168d034c..169dd507a 100644
--- a/gtk/ScintillaGTKAccessible.h
+++ b/gtk/ScintillaGTKAccessible.h
@@ -6,7 +6,7 @@
#ifndef SCINTILLAGTKACCESSIBLE_H
#define SCINTILLAGTKACCESSIBLE_H
-namespace Scintilla {
+namespace Scintilla::Internal {
#ifndef ATK_CHECK_VERSION
# define ATK_CHECK_VERSION(x, y, z) 0
@@ -24,25 +24,25 @@ private:
bool Enabled() const;
void UpdateCursor();
- void Notify(GtkWidget *widget, gint code, SCNotification *nt);
- static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) {
+ void Notify(GtkWidget *widget, gint code, Scintilla::NotificationData *nt);
+ static void SciNotify(GtkWidget *widget, gint code, Scintilla::NotificationData *nt, gpointer data) {
try {
static_cast<ScintillaGTKAccessible*>(data)->Notify(widget, code, nt);
} catch (...) {}
}
Sci::Position ByteOffsetFromCharacterOffset(Sci::Position startByte, int characterOffset) {
- if (!(sci->pdoc->LineCharacterIndex() & SC_LINECHARACTERINDEX_UTF32)) {
+ if (!FlagSet(sci->pdoc->LineCharacterIndex(), Scintilla::LineCharacterIndexType::Utf32)) {
return startByte + characterOffset;
}
if (characterOffset > 0) {
// Try and reduce the range by reverse-looking into the character offset cache
Sci::Line lineStart = sci->pdoc->LineFromPosition(startByte);
- Sci::Position posStart = sci->pdoc->IndexLineStart(lineStart, SC_LINECHARACTERINDEX_UTF32);
- Sci::Line line = sci->pdoc->LineFromPositionIndex(posStart + characterOffset, SC_LINECHARACTERINDEX_UTF32);
+ Sci::Position posStart = sci->pdoc->IndexLineStart(lineStart, Scintilla::LineCharacterIndexType::Utf32);
+ Sci::Line line = sci->pdoc->LineFromPositionIndex(posStart + characterOffset, Scintilla::LineCharacterIndexType::Utf32);
if (line != lineStart) {
startByte += sci->pdoc->LineStart(line) - sci->pdoc->LineStart(lineStart);
- characterOffset -= sci->pdoc->IndexLineStart(line, SC_LINECHARACTERINDEX_UTF32) - posStart;
+ characterOffset -= sci->pdoc->IndexLineStart(line, Scintilla::LineCharacterIndexType::Utf32) - posStart;
}
}
Sci::Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset);
@@ -62,12 +62,12 @@ private:
}
Sci::Position CharacterOffsetFromByteOffset(Sci::Position byteOffset) {
- if (!(sci->pdoc->LineCharacterIndex() & SC_LINECHARACTERINDEX_UTF32)) {
+ if (!FlagSet(sci->pdoc->LineCharacterIndex(), Scintilla::LineCharacterIndexType::Utf32)) {
return byteOffset;
}
const Sci::Line line = sci->pdoc->LineFromPosition(byteOffset);
const Sci::Position lineStart = sci->pdoc->LineStart(line);
- return sci->pdoc->IndexLineStart(line, SC_LINECHARACTERINDEX_UTF32) + sci->pdoc->CountCharacters(lineStart, byteOffset);
+ return sci->pdoc->IndexLineStart(line, Scintilla::LineCharacterIndexType::Utf32) + sci->pdoc->CountCharacters(lineStart, byteOffset);
}
void CharacterRangeFromByteRange(Sci::Position startByte, Sci::Position endByte, int *startChar, int *endChar) {
diff --git a/gtk/deps.mak b/gtk/deps.mak
index c98dddfa1..11ed82d2b 100644
--- a/gtk/deps.mak
+++ b/gtk/deps.mak
@@ -3,6 +3,8 @@ PlatGTK.o: \
PlatGTK.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
../include/Scintilla.h \
../include/Sci_Position.h \
@@ -14,6 +16,9 @@ ScintillaGTK.o: \
ScintillaGTK.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
+ ../include/ScintillaStructures.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
@@ -56,6 +61,9 @@ ScintillaGTKAccessible.o: \
ScintillaGTKAccessible.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
+ ../include/ScintillaStructures.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
@@ -96,9 +104,9 @@ AutoComplete.o: \
../src/AutoComplete.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
../src/CharacterType.h \
../src/Position.h \
../src/AutoComplete.h
@@ -106,9 +114,9 @@ CallTip.o: \
../src/CallTip.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
../src/Position.h \
../src/CallTip.h
CaseConvert.o: \
@@ -122,8 +130,8 @@ CaseFolder.o: \
CellBuffer.o: \
../src/CellBuffer.cxx \
../src/Debugging.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Position.h \
../src/SplitVector.h \
../src/Partitioning.h \
@@ -155,8 +163,8 @@ DBCS.o: \
Decoration.o: \
../src/Decoration.cxx \
../src/Debugging.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Position.h \
../src/SplitVector.h \
../src/Partitioning.h \
@@ -168,7 +176,8 @@ Document.o: \
../include/ILoader.h \
../include/Sci_Position.h \
../include/ILexer.h \
- ../include/Scintilla.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/CharacterType.h \
../src/CharacterCategoryMap.h \
../src/Position.h \
@@ -188,11 +197,12 @@ EditModel.o: \
../src/EditModel.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
../include/ILexer.h \
- ../include/Scintilla.h \
../src/CharacterCategoryMap.h \
../src/Position.h \
../src/UniqueString.h \
@@ -218,11 +228,13 @@ Editor.o: \
../src/Editor.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
+ ../include/ScintillaStructures.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
../include/ILexer.h \
- ../include/Scintilla.h \
../src/CharacterType.h \
../src/CharacterCategoryMap.h \
../src/Position.h \
@@ -254,11 +266,13 @@ EditView.o: \
../src/EditView.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
+ ../include/ScintillaStructures.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
../include/ILexer.h \
- ../include/Scintilla.h \
../src/CharacterType.h \
../src/CharacterCategoryMap.h \
../src/Position.h \
@@ -292,24 +306,24 @@ Indicator.o: \
../src/Indicator.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
../src/Indicator.h \
../src/XPM.h
KeyMap.o: \
../src/KeyMap.cxx \
../src/Debugging.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/KeyMap.h
LineMarker.o: \
../src/LineMarker.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
../src/XPM.h \
../src/LineMarker.h \
../src/UniConversion.h
@@ -317,11 +331,13 @@ MarginView.o: \
../src/MarginView.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
+ ../include/ScintillaStructures.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
../include/ILexer.h \
- ../include/Scintilla.h \
../src/CharacterCategoryMap.h \
../src/Position.h \
../src/UniqueString.h \
@@ -349,9 +365,9 @@ PerLine.o: \
../src/PerLine.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
../src/Position.h \
../src/SplitVector.h \
../src/Partitioning.h \
@@ -361,11 +377,12 @@ PositionCache.o: \
../src/PositionCache.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
../include/ILexer.h \
- ../include/Scintilla.h \
../src/CharacterCategoryMap.h \
../src/Position.h \
../src/UniqueString.h \
@@ -394,8 +411,8 @@ RESearch.o: \
RunStyles.o: \
../src/RunStyles.cxx \
../src/Debugging.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Position.h \
../src/SplitVector.h \
../src/Partitioning.h \
@@ -404,11 +421,13 @@ ScintillaBase.o: \
../src/ScintillaBase.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
+ ../include/ScintillaStructures.h \
../src/Platform.h \
../include/ILoader.h \
../include/Sci_Position.h \
../include/ILexer.h \
- ../include/Scintilla.h \
../src/CharacterCategoryMap.h \
../src/Position.h \
../src/UniqueString.h \
@@ -438,17 +457,17 @@ ScintillaBase.o: \
Selection.o: \
../src/Selection.cxx \
../src/Debugging.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Position.h \
../src/Selection.h
Style.o: \
../src/Style.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
../src/Style.h
UniConversion.o: \
../src/UniConversion.cxx \
@@ -460,9 +479,9 @@ ViewStyle.o: \
../src/ViewStyle.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
+ ../include/ScintillaMessages.h \
../src/Platform.h \
- ../include/Scintilla.h \
- ../include/Sci_Position.h \
../src/Position.h \
../src/UniqueString.h \
../src/Indicator.h \
@@ -474,5 +493,6 @@ XPM.o: \
../src/XPM.cxx \
../src/Debugging.h \
../src/Geometry.h \
+ ../include/ScintillaTypes.h \
../src/Platform.h \
../src/XPM.h
diff --git a/include/ILoader.h b/include/ILoader.h
index e989de873..2fa69f527 100644
--- a/include/ILoader.h
+++ b/include/ILoader.h
@@ -10,6 +10,8 @@
#include "Sci_Position.h"
+namespace Scintilla {
+
class ILoader {
public:
virtual int SCI_METHOD Release() = 0;
@@ -18,4 +20,6 @@ public:
virtual void * SCI_METHOD ConvertToDocument() = 0;
};
+}
+
#endif
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 7304cad56..7ec3e9e7b 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -885,6 +885,7 @@ val SC_INDICVALUEBIT=0x1000000
val SC_INDICVALUEMASK=0xFFFFFF
enu IndicFlag=SC_INDICFLAG_
+val SC_INDICFLAG_NONE=0
val SC_INDICFLAG_VALUEFORE=1
ali SC_INDICFLAG_VALUEFORE=VALUE_FORE
@@ -1416,6 +1417,7 @@ fun line DocLineFromVisible=2221(line displayLine,)
fun line WrapCount=2235(line docLine,)
enu FoldLevel=SC_FOLDLEVEL
+val SC_FOLDLEVELNONE=0x0
val SC_FOLDLEVELBASE=0x400
val SC_FOLDLEVELWHITEFLAG=0x1000
val SC_FOLDLEVELHEADERFLAG=0x2000
@@ -1501,6 +1503,7 @@ fun void FoldAll=2662(FoldAction action,)
fun void EnsureVisible=2232(line line,)
enu AutomaticFold=SC_AUTOMATICFOLD_
+val SC_AUTOMATICFOLD_NONE=0x0000
val SC_AUTOMATICFOLD_SHOW=0x0001
val SC_AUTOMATICFOLD_CLICK=0x0002
val SC_AUTOMATICFOLD_CHANGE=0x0004
@@ -1512,6 +1515,7 @@ set void SetAutomaticFold=2663(AutomaticFold automaticFold,)
get AutomaticFold GetAutomaticFold=2664(,)
enu FoldFlag=SC_FOLDFLAG_
+val SC_FOLDFLAG_NONE=0x0000
val SC_FOLDFLAG_LINEBEFORE_EXPANDED=0x0002
val SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004
val SC_FOLDFLAG_LINEAFTER_EXPANDED=0x0008
@@ -3169,6 +3173,7 @@ ali SC_MOD_CHANGEEOLANNOTATION=CHANGE_E_O_L_ANNOTATION
ali SC_MODEVENTMASKALL=EVENT_MASK_ALL
enu Update=SC_UPDATE_
+val SC_UPDATE_NONE=0x0
val SC_UPDATE_CONTENT=0x1
val SC_UPDATE_SELECTION=0x2
val SC_UPDATE_V_SCROLL=0x4
@@ -3178,6 +3183,7 @@ val SC_UPDATE_H_SCROLL=0x8
# and should have had exactly the same values as the EN_* constants.
# Unfortunately the SETFOCUS and KILLFOCUS are flipped over from EN_*
# As clients depend on these constants, this will not be changed.
+enu FocusChange=SCEN_
val SCEN_CHANGE=768
val SCEN_SETFOCUS=512
val SCEN_KILLFOCUS=256
diff --git a/include/ScintillaMessages.h b/include/ScintillaMessages.h
new file mode 100644
index 000000000..ba2a3f2cd
--- /dev/null
+++ b/include/ScintillaMessages.h
@@ -0,0 +1,778 @@
+// Scintilla source code edit control
+/** @file ScintillaMessages.h
+ ** Enumerate the messages that can be sent to Scintilla.
+ **/
+// Copyright 1998-2019 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+/* Most of this file is automatically generated from the Scintilla.iface interface definition
+ * file which contains any comments about the definitions. ScintillaAPIFacer.py does the generation. */
+
+#ifndef SCINTILLAMESSAGES_H
+#define SCINTILLAMESSAGES_H
+
+namespace Scintilla {
+
+// Enumerations
+//++Autogenerated -- start of section automatically generated from Scintilla.iface
+enum class Message {
+ AddText = 2001,
+ AddStyledText = 2002,
+ InsertText = 2003,
+ ChangeInsertion = 2672,
+ ClearAll = 2004,
+ DeleteRange = 2645,
+ ClearDocumentStyle = 2005,
+ GetLength = 2006,
+ GetCharAt = 2007,
+ GetCurrentPos = 2008,
+ GetAnchor = 2009,
+ GetStyleAt = 2010,
+ Redo = 2011,
+ SetUndoCollection = 2012,
+ SelectAll = 2013,
+ SetSavePoint = 2014,
+ GetStyledText = 2015,
+ CanRedo = 2016,
+ MarkerLineFromHandle = 2017,
+ MarkerDeleteHandle = 2018,
+ MarkerHandleFromLine = 2732,
+ MarkerNumberFromLine = 2733,
+ GetUndoCollection = 2019,
+ GetViewWS = 2020,
+ SetViewWS = 2021,
+ GetTabDrawMode = 2698,
+ SetTabDrawMode = 2699,
+ PositionFromPoint = 2022,
+ PositionFromPointClose = 2023,
+ GotoLine = 2024,
+ GotoPos = 2025,
+ SetAnchor = 2026,
+ GetCurLine = 2027,
+ GetEndStyled = 2028,
+ ConvertEOLs = 2029,
+ GetEOLMode = 2030,
+ SetEOLMode = 2031,
+ StartStyling = 2032,
+ SetStyling = 2033,
+ GetBufferedDraw = 2034,
+ SetBufferedDraw = 2035,
+ SetTabWidth = 2036,
+ GetTabWidth = 2121,
+ SetTabMinimumWidth = 2724,
+ GetTabMinimumWidth = 2725,
+ ClearTabStops = 2675,
+ AddTabStop = 2676,
+ GetNextTabStop = 2677,
+ SetCodePage = 2037,
+ SetFontLocale = 2760,
+ GetFontLocale = 2761,
+ GetIMEInteraction = 2678,
+ SetIMEInteraction = 2679,
+ MarkerDefine = 2040,
+ MarkerSetFore = 2041,
+ MarkerSetBack = 2042,
+ MarkerSetBackSelected = 2292,
+ MarkerSetForeTranslucent = 2294,
+ MarkerSetBackTranslucent = 2295,
+ MarkerSetBackSelectedTranslucent = 2296,
+ MarkerSetStrokeWidth = 2297,
+ MarkerEnableHighlight = 2293,
+ MarkerAdd = 2043,
+ MarkerDelete = 2044,
+ MarkerDeleteAll = 2045,
+ MarkerGet = 2046,
+ MarkerNext = 2047,
+ MarkerPrevious = 2048,
+ MarkerDefinePixmap = 2049,
+ MarkerAddSet = 2466,
+ MarkerSetAlpha = 2476,
+ MarkerGetLayer = 2734,
+ MarkerSetLayer = 2735,
+ SetMarginTypeN = 2240,
+ GetMarginTypeN = 2241,
+ SetMarginWidthN = 2242,
+ GetMarginWidthN = 2243,
+ SetMarginMaskN = 2244,
+ GetMarginMaskN = 2245,
+ SetMarginSensitiveN = 2246,
+ GetMarginSensitiveN = 2247,
+ SetMarginCursorN = 2248,
+ GetMarginCursorN = 2249,
+ SetMarginBackN = 2250,
+ GetMarginBackN = 2251,
+ SetMargins = 2252,
+ GetMargins = 2253,
+ StyleClearAll = 2050,
+ StyleSetFore = 2051,
+ StyleSetBack = 2052,
+ StyleSetBold = 2053,
+ StyleSetItalic = 2054,
+ StyleSetSize = 2055,
+ StyleSetFont = 2056,
+ StyleSetEOLFilled = 2057,
+ StyleResetDefault = 2058,
+ StyleSetUnderline = 2059,
+ StyleGetFore = 2481,
+ StyleGetBack = 2482,
+ StyleGetBold = 2483,
+ StyleGetItalic = 2484,
+ StyleGetSize = 2485,
+ StyleGetFont = 2486,
+ StyleGetEOLFilled = 2487,
+ StyleGetUnderline = 2488,
+ StyleGetCase = 2489,
+ StyleGetCharacterSet = 2490,
+ StyleGetVisible = 2491,
+ StyleGetChangeable = 2492,
+ StyleGetHotSpot = 2493,
+ StyleSetCase = 2060,
+ StyleSetSizeFractional = 2061,
+ StyleGetSizeFractional = 2062,
+ StyleSetWeight = 2063,
+ StyleGetWeight = 2064,
+ StyleSetCharacterSet = 2066,
+ StyleSetHotSpot = 2409,
+ SetElementColour = 2753,
+ GetElementColour = 2754,
+ ResetElementColour = 2755,
+ GetElementIsSet = 2756,
+ GetElementAllowsTranslucent = 2757,
+ GetElementBaseColour = 2758,
+ SetSelFore = 2067,
+ SetSelBack = 2068,
+ GetSelAlpha = 2477,
+ SetSelAlpha = 2478,
+ GetSelEOLFilled = 2479,
+ SetSelEOLFilled = 2480,
+ GetSelectionLayer = 2762,
+ SetSelectionLayer = 2763,
+ GetCaretLineLayer = 2764,
+ SetCaretLineLayer = 2765,
+ SetCaretFore = 2069,
+ AssignCmdKey = 2070,
+ ClearCmdKey = 2071,
+ ClearAllCmdKeys = 2072,
+ SetStylingEx = 2073,
+ StyleSetVisible = 2074,
+ GetCaretPeriod = 2075,
+ SetCaretPeriod = 2076,
+ SetWordChars = 2077,
+ GetWordChars = 2646,
+ SetCharacterCategoryOptimization = 2720,
+ GetCharacterCategoryOptimization = 2721,
+ BeginUndoAction = 2078,
+ EndUndoAction = 2079,
+ IndicSetStyle = 2080,
+ IndicGetStyle = 2081,
+ IndicSetFore = 2082,
+ IndicGetFore = 2083,
+ IndicSetUnder = 2510,
+ IndicGetUnder = 2511,
+ IndicSetHoverStyle = 2680,
+ IndicGetHoverStyle = 2681,
+ IndicSetHoverFore = 2682,
+ IndicGetHoverFore = 2683,
+ IndicSetFlags = 2684,
+ IndicGetFlags = 2685,
+ IndicSetStrokeWidth = 2751,
+ IndicGetStrokeWidth = 2752,
+ SetWhitespaceFore = 2084,
+ SetWhitespaceBack = 2085,
+ SetWhitespaceSize = 2086,
+ GetWhitespaceSize = 2087,
+ SetLineState = 2092,
+ GetLineState = 2093,
+ GetMaxLineState = 2094,
+ GetCaretLineVisible = 2095,
+ SetCaretLineVisible = 2096,
+ GetCaretLineBack = 2097,
+ SetCaretLineBack = 2098,
+ GetCaretLineFrame = 2704,
+ SetCaretLineFrame = 2705,
+ StyleSetChangeable = 2099,
+ AutoCShow = 2100,
+ AutoCCancel = 2101,
+ AutoCActive = 2102,
+ AutoCPosStart = 2103,
+ AutoCComplete = 2104,
+ AutoCStops = 2105,
+ AutoCSetSeparator = 2106,
+ AutoCGetSeparator = 2107,
+ AutoCSelect = 2108,
+ AutoCSetCancelAtStart = 2110,
+ AutoCGetCancelAtStart = 2111,
+ AutoCSetFillUps = 2112,
+ AutoCSetChooseSingle = 2113,
+ AutoCGetChooseSingle = 2114,
+ AutoCSetIgnoreCase = 2115,
+ AutoCGetIgnoreCase = 2116,
+ UserListShow = 2117,
+ AutoCSetAutoHide = 2118,
+ AutoCGetAutoHide = 2119,
+ AutoCSetDropRestOfWord = 2270,
+ AutoCGetDropRestOfWord = 2271,
+ RegisterImage = 2405,
+ ClearRegisteredImages = 2408,
+ AutoCGetTypeSeparator = 2285,
+ AutoCSetTypeSeparator = 2286,
+ AutoCSetMaxWidth = 2208,
+ AutoCGetMaxWidth = 2209,
+ AutoCSetMaxHeight = 2210,
+ AutoCGetMaxHeight = 2211,
+ SetIndent = 2122,
+ GetIndent = 2123,
+ SetUseTabs = 2124,
+ GetUseTabs = 2125,
+ SetLineIndentation = 2126,
+ GetLineIndentation = 2127,
+ GetLineIndentPosition = 2128,
+ GetColumn = 2129,
+ CountCharacters = 2633,
+ CountCodeUnits = 2715,
+ SetHScrollBar = 2130,
+ GetHScrollBar = 2131,
+ SetIndentationGuides = 2132,
+ GetIndentationGuides = 2133,
+ SetHighlightGuide = 2134,
+ GetHighlightGuide = 2135,
+ GetLineEndPosition = 2136,
+ GetCodePage = 2137,
+ GetCaretFore = 2138,
+ GetReadOnly = 2140,
+ SetCurrentPos = 2141,
+ SetSelectionStart = 2142,
+ GetSelectionStart = 2143,
+ SetSelectionEnd = 2144,
+ GetSelectionEnd = 2145,
+ SetEmptySelection = 2556,
+ SetPrintMagnification = 2146,
+ GetPrintMagnification = 2147,
+ SetPrintColourMode = 2148,
+ GetPrintColourMode = 2149,
+ FindText = 2150,
+ FormatRange = 2151,
+ GetFirstVisibleLine = 2152,
+ GetLine = 2153,
+ GetLineCount = 2154,
+ SetMarginLeft = 2155,
+ GetMarginLeft = 2156,
+ SetMarginRight = 2157,
+ GetMarginRight = 2158,
+ GetModify = 2159,
+ SetSel = 2160,
+ GetSelText = 2161,
+ GetTextRange = 2162,
+ HideSelection = 2163,
+ PointXFromPosition = 2164,
+ PointYFromPosition = 2165,
+ LineFromPosition = 2166,
+ PositionFromLine = 2167,
+ LineScroll = 2168,
+ ScrollCaret = 2169,
+ ScrollRange = 2569,
+ ReplaceSel = 2170,
+ SetReadOnly = 2171,
+ Null = 2172,
+ CanPaste = 2173,
+ CanUndo = 2174,
+ EmptyUndoBuffer = 2175,
+ Undo = 2176,
+ Cut = 2177,
+ Copy = 2178,
+ Paste = 2179,
+ Clear = 2180,
+ SetText = 2181,
+ GetText = 2182,
+ GetTextLength = 2183,
+ GetDirectFunction = 2184,
+ GetDirectPointer = 2185,
+ SetOvertype = 2186,
+ GetOvertype = 2187,
+ SetCaretWidth = 2188,
+ GetCaretWidth = 2189,
+ SetTargetStart = 2190,
+ GetTargetStart = 2191,
+ SetTargetStartVirtualSpace = 2728,
+ GetTargetStartVirtualSpace = 2729,
+ SetTargetEnd = 2192,
+ GetTargetEnd = 2193,
+ SetTargetEndVirtualSpace = 2730,
+ GetTargetEndVirtualSpace = 2731,
+ SetTargetRange = 2686,
+ GetTargetText = 2687,
+ TargetFromSelection = 2287,
+ TargetWholeDocument = 2690,
+ ReplaceTarget = 2194,
+ ReplaceTargetRE = 2195,
+ SearchInTarget = 2197,
+ SetSearchFlags = 2198,
+ GetSearchFlags = 2199,
+ CallTipShow = 2200,
+ CallTipCancel = 2201,
+ CallTipActive = 2202,
+ CallTipPosStart = 2203,
+ CallTipSetPosStart = 2214,
+ CallTipSetHlt = 2204,
+ CallTipSetBack = 2205,
+ CallTipSetFore = 2206,
+ CallTipSetForeHlt = 2207,
+ CallTipUseStyle = 2212,
+ CallTipSetPosition = 2213,
+ VisibleFromDocLine = 2220,
+ DocLineFromVisible = 2221,
+ WrapCount = 2235,
+ SetFoldLevel = 2222,
+ GetFoldLevel = 2223,
+ GetLastChild = 2224,
+ GetFoldParent = 2225,
+ ShowLines = 2226,
+ HideLines = 2227,
+ GetLineVisible = 2228,
+ GetAllLinesVisible = 2236,
+ SetFoldExpanded = 2229,
+ GetFoldExpanded = 2230,
+ ToggleFold = 2231,
+ ToggleFoldShowText = 2700,
+ FoldDisplayTextSetStyle = 2701,
+ FoldDisplayTextGetStyle = 2707,
+ SetDefaultFoldDisplayText = 2722,
+ GetDefaultFoldDisplayText = 2723,
+ FoldLine = 2237,
+ FoldChildren = 2238,
+ ExpandChildren = 2239,
+ FoldAll = 2662,
+ EnsureVisible = 2232,
+ SetAutomaticFold = 2663,
+ GetAutomaticFold = 2664,
+ SetFoldFlags = 2233,
+ EnsureVisibleEnforcePolicy = 2234,
+ SetTabIndents = 2260,
+ GetTabIndents = 2261,
+ SetBackSpaceUnIndents = 2262,
+ GetBackSpaceUnIndents = 2263,
+ SetMouseDwellTime = 2264,
+ GetMouseDwellTime = 2265,
+ WordStartPosition = 2266,
+ WordEndPosition = 2267,
+ IsRangeWord = 2691,
+ SetIdleStyling = 2692,
+ GetIdleStyling = 2693,
+ SetWrapMode = 2268,
+ GetWrapMode = 2269,
+ SetWrapVisualFlags = 2460,
+ GetWrapVisualFlags = 2461,
+ SetWrapVisualFlagsLocation = 2462,
+ GetWrapVisualFlagsLocation = 2463,
+ SetWrapStartIndent = 2464,
+ GetWrapStartIndent = 2465,
+ SetWrapIndentMode = 2472,
+ GetWrapIndentMode = 2473,
+ SetLayoutCache = 2272,
+ GetLayoutCache = 2273,
+ SetScrollWidth = 2274,
+ GetScrollWidth = 2275,
+ SetScrollWidthTracking = 2516,
+ GetScrollWidthTracking = 2517,
+ TextWidth = 2276,
+ SetEndAtLastLine = 2277,
+ GetEndAtLastLine = 2278,
+ TextHeight = 2279,
+ SetVScrollBar = 2280,
+ GetVScrollBar = 2281,
+ AppendText = 2282,
+ GetPhasesDraw = 2673,
+ SetPhasesDraw = 2674,
+ SetFontQuality = 2611,
+ GetFontQuality = 2612,
+ SetFirstVisibleLine = 2613,
+ SetMultiPaste = 2614,
+ GetMultiPaste = 2615,
+ GetTag = 2616,
+ LinesJoin = 2288,
+ LinesSplit = 2289,
+ SetFoldMarginColour = 2290,
+ SetFoldMarginHiColour = 2291,
+ SetAccessibility = 2702,
+ GetAccessibility = 2703,
+ LineDown = 2300,
+ LineDownExtend = 2301,
+ LineUp = 2302,
+ LineUpExtend = 2303,
+ CharLeft = 2304,
+ CharLeftExtend = 2305,
+ CharRight = 2306,
+ CharRightExtend = 2307,
+ WordLeft = 2308,
+ WordLeftExtend = 2309,
+ WordRight = 2310,
+ WordRightExtend = 2311,
+ Home = 2312,
+ HomeExtend = 2313,
+ LineEnd = 2314,
+ LineEndExtend = 2315,
+ DocumentStart = 2316,
+ DocumentStartExtend = 2317,
+ DocumentEnd = 2318,
+ DocumentEndExtend = 2319,
+ PageUp = 2320,
+ PageUpExtend = 2321,
+ PageDown = 2322,
+ PageDownExtend = 2323,
+ EditToggleOvertype = 2324,
+ Cancel = 2325,
+ DeleteBack = 2326,
+ Tab = 2327,
+ BackTab = 2328,
+ NewLine = 2329,
+ FormFeed = 2330,
+ VCHome = 2331,
+ VCHomeExtend = 2332,
+ ZoomIn = 2333,
+ ZoomOut = 2334,
+ DelWordLeft = 2335,
+ DelWordRight = 2336,
+ DelWordRightEnd = 2518,
+ LineCut = 2337,
+ LineDelete = 2338,
+ LineTranspose = 2339,
+ LineReverse = 2354,
+ LineDuplicate = 2404,
+ LowerCase = 2340,
+ UpperCase = 2341,
+ LineScrollDown = 2342,
+ LineScrollUp = 2343,
+ DeleteBackNotLine = 2344,
+ HomeDisplay = 2345,
+ HomeDisplayExtend = 2346,
+ LineEndDisplay = 2347,
+ LineEndDisplayExtend = 2348,
+ HomeWrap = 2349,
+ HomeWrapExtend = 2450,
+ LineEndWrap = 2451,
+ LineEndWrapExtend = 2452,
+ VCHomeWrap = 2453,
+ VCHomeWrapExtend = 2454,
+ LineCopy = 2455,
+ MoveCaretInsideView = 2401,
+ LineLength = 2350,
+ BraceHighlight = 2351,
+ BraceHighlightIndicator = 2498,
+ BraceBadLight = 2352,
+ BraceBadLightIndicator = 2499,
+ BraceMatch = 2353,
+ BraceMatchNext = 2369,
+ GetViewEOL = 2355,
+ SetViewEOL = 2356,
+ GetDocPointer = 2357,
+ SetDocPointer = 2358,
+ SetModEventMask = 2359,
+ GetEdgeColumn = 2360,
+ SetEdgeColumn = 2361,
+ GetEdgeMode = 2362,
+ SetEdgeMode = 2363,
+ GetEdgeColour = 2364,
+ SetEdgeColour = 2365,
+ MultiEdgeAddLine = 2694,
+ MultiEdgeClearAll = 2695,
+ GetMultiEdgeColumn = 2749,
+ SearchAnchor = 2366,
+ SearchNext = 2367,
+ SearchPrev = 2368,
+ LinesOnScreen = 2370,
+ UsePopUp = 2371,
+ SelectionIsRectangle = 2372,
+ SetZoom = 2373,
+ GetZoom = 2374,
+ CreateDocument = 2375,
+ AddRefDocument = 2376,
+ ReleaseDocument = 2377,
+ GetDocumentOptions = 2379,
+ GetModEventMask = 2378,
+ SetCommandEvents = 2717,
+ GetCommandEvents = 2718,
+ SetFocus = 2380,
+ GetFocus = 2381,
+ SetStatus = 2382,
+ GetStatus = 2383,
+ SetMouseDownCaptures = 2384,
+ GetMouseDownCaptures = 2385,
+ SetMouseWheelCaptures = 2696,
+ GetMouseWheelCaptures = 2697,
+ SetCursor = 2386,
+ GetCursor = 2387,
+ SetControlCharSymbol = 2388,
+ GetControlCharSymbol = 2389,
+ WordPartLeft = 2390,
+ WordPartLeftExtend = 2391,
+ WordPartRight = 2392,
+ WordPartRightExtend = 2393,
+ SetVisiblePolicy = 2394,
+ DelLineLeft = 2395,
+ DelLineRight = 2396,
+ SetXOffset = 2397,
+ GetXOffset = 2398,
+ ChooseCaretX = 2399,
+ GrabFocus = 2400,
+ SetXCaretPolicy = 2402,
+ SetYCaretPolicy = 2403,
+ SetPrintWrapMode = 2406,
+ GetPrintWrapMode = 2407,
+ SetHotspotActiveFore = 2410,
+ GetHotspotActiveFore = 2494,
+ SetHotspotActiveBack = 2411,
+ GetHotspotActiveBack = 2495,
+ SetHotspotActiveUnderline = 2412,
+ GetHotspotActiveUnderline = 2496,
+ SetHotspotSingleLine = 2421,
+ GetHotspotSingleLine = 2497,
+ ParaDown = 2413,
+ ParaDownExtend = 2414,
+ ParaUp = 2415,
+ ParaUpExtend = 2416,
+ PositionBefore = 2417,
+ PositionAfter = 2418,
+ PositionRelative = 2670,
+ PositionRelativeCodeUnits = 2716,
+ CopyRange = 2419,
+ CopyText = 2420,
+ SetSelectionMode = 2422,
+ GetSelectionMode = 2423,
+ GetMoveExtendsSelection = 2706,
+ GetLineSelStartPosition = 2424,
+ GetLineSelEndPosition = 2425,
+ LineDownRectExtend = 2426,
+ LineUpRectExtend = 2427,
+ CharLeftRectExtend = 2428,
+ CharRightRectExtend = 2429,
+ HomeRectExtend = 2430,
+ VCHomeRectExtend = 2431,
+ LineEndRectExtend = 2432,
+ PageUpRectExtend = 2433,
+ PageDownRectExtend = 2434,
+ StutteredPageUp = 2435,
+ StutteredPageUpExtend = 2436,
+ StutteredPageDown = 2437,
+ StutteredPageDownExtend = 2438,
+ WordLeftEnd = 2439,
+ WordLeftEndExtend = 2440,
+ WordRightEnd = 2441,
+ WordRightEndExtend = 2442,
+ SetWhitespaceChars = 2443,
+ GetWhitespaceChars = 2647,
+ SetPunctuationChars = 2648,
+ GetPunctuationChars = 2649,
+ SetCharsDefault = 2444,
+ AutoCGetCurrent = 2445,
+ AutoCGetCurrentText = 2610,
+ AutoCSetCaseInsensitiveBehaviour = 2634,
+ AutoCGetCaseInsensitiveBehaviour = 2635,
+ AutoCSetMulti = 2636,
+ AutoCGetMulti = 2637,
+ AutoCSetOrder = 2660,
+ AutoCGetOrder = 2661,
+ Allocate = 2446,
+ TargetAsUTF8 = 2447,
+ SetLengthForEncode = 2448,
+ EncodedFromUTF8 = 2449,
+ FindColumn = 2456,
+ GetCaretSticky = 2457,
+ SetCaretSticky = 2458,
+ ToggleCaretSticky = 2459,
+ SetPasteConvertEndings = 2467,
+ GetPasteConvertEndings = 2468,
+ SelectionDuplicate = 2469,
+ SetCaretLineBackAlpha = 2470,
+ GetCaretLineBackAlpha = 2471,
+ SetCaretStyle = 2512,
+ GetCaretStyle = 2513,
+ SetIndicatorCurrent = 2500,
+ GetIndicatorCurrent = 2501,
+ SetIndicatorValue = 2502,
+ GetIndicatorValue = 2503,
+ IndicatorFillRange = 2504,
+ IndicatorClearRange = 2505,
+ IndicatorAllOnFor = 2506,
+ IndicatorValueAt = 2507,
+ IndicatorStart = 2508,
+ IndicatorEnd = 2509,
+ SetPositionCache = 2514,
+ GetPositionCache = 2515,
+ CopyAllowLine = 2519,
+ GetCharacterPointer = 2520,
+ GetRangePointer = 2643,
+ GetGapPosition = 2644,
+ IndicSetAlpha = 2523,
+ IndicGetAlpha = 2524,
+ IndicSetOutlineAlpha = 2558,
+ IndicGetOutlineAlpha = 2559,
+ SetExtraAscent = 2525,
+ GetExtraAscent = 2526,
+ SetExtraDescent = 2527,
+ GetExtraDescent = 2528,
+ MarkerSymbolDefined = 2529,
+ MarginSetText = 2530,
+ MarginGetText = 2531,
+ MarginSetStyle = 2532,
+ MarginGetStyle = 2533,
+ MarginSetStyles = 2534,
+ MarginGetStyles = 2535,
+ MarginTextClearAll = 2536,
+ MarginSetStyleOffset = 2537,
+ MarginGetStyleOffset = 2538,
+ SetMarginOptions = 2539,
+ GetMarginOptions = 2557,
+ AnnotationSetText = 2540,
+ AnnotationGetText = 2541,
+ AnnotationSetStyle = 2542,
+ AnnotationGetStyle = 2543,
+ AnnotationSetStyles = 2544,
+ AnnotationGetStyles = 2545,
+ AnnotationGetLines = 2546,
+ AnnotationClearAll = 2547,
+ AnnotationSetVisible = 2548,
+ AnnotationGetVisible = 2549,
+ AnnotationSetStyleOffset = 2550,
+ AnnotationGetStyleOffset = 2551,
+ ReleaseAllExtendedStyles = 2552,
+ AllocateExtendedStyles = 2553,
+ AddUndoAction = 2560,
+ CharPositionFromPoint = 2561,
+ CharPositionFromPointClose = 2562,
+ SetMouseSelectionRectangularSwitch = 2668,
+ GetMouseSelectionRectangularSwitch = 2669,
+ SetMultipleSelection = 2563,
+ GetMultipleSelection = 2564,
+ SetAdditionalSelectionTyping = 2565,
+ GetAdditionalSelectionTyping = 2566,
+ SetAdditionalCaretsBlink = 2567,
+ GetAdditionalCaretsBlink = 2568,
+ SetAdditionalCaretsVisible = 2608,
+ GetAdditionalCaretsVisible = 2609,
+ GetSelections = 2570,
+ GetSelectionEmpty = 2650,
+ ClearSelections = 2571,
+ SetSelection = 2572,
+ AddSelection = 2573,
+ DropSelectionN = 2671,
+ SetMainSelection = 2574,
+ GetMainSelection = 2575,
+ SetSelectionNCaret = 2576,
+ GetSelectionNCaret = 2577,
+ SetSelectionNAnchor = 2578,
+ GetSelectionNAnchor = 2579,
+ SetSelectionNCaretVirtualSpace = 2580,
+ GetSelectionNCaretVirtualSpace = 2581,
+ SetSelectionNAnchorVirtualSpace = 2582,
+ GetSelectionNAnchorVirtualSpace = 2583,
+ SetSelectionNStart = 2584,
+ GetSelectionNStart = 2585,
+ GetSelectionNStartVirtualSpace = 2726,
+ SetSelectionNEnd = 2586,
+ GetSelectionNEndVirtualSpace = 2727,
+ GetSelectionNEnd = 2587,
+ SetRectangularSelectionCaret = 2588,
+ GetRectangularSelectionCaret = 2589,
+ SetRectangularSelectionAnchor = 2590,
+ GetRectangularSelectionAnchor = 2591,
+ SetRectangularSelectionCaretVirtualSpace = 2592,
+ GetRectangularSelectionCaretVirtualSpace = 2593,
+ SetRectangularSelectionAnchorVirtualSpace = 2594,
+ GetRectangularSelectionAnchorVirtualSpace = 2595,
+ SetVirtualSpaceOptions = 2596,
+ GetVirtualSpaceOptions = 2597,
+ SetRectangularSelectionModifier = 2598,
+ GetRectangularSelectionModifier = 2599,
+ SetAdditionalSelFore = 2600,
+ SetAdditionalSelBack = 2601,
+ SetAdditionalSelAlpha = 2602,
+ GetAdditionalSelAlpha = 2603,
+ SetAdditionalCaretFore = 2604,
+ GetAdditionalCaretFore = 2605,
+ RotateSelection = 2606,
+ SwapMainAnchorCaret = 2607,
+ MultipleSelectAddNext = 2688,
+ MultipleSelectAddEach = 2689,
+ ChangeLexerState = 2617,
+ ContractedFoldNext = 2618,
+ VerticalCentreCaret = 2619,
+ MoveSelectedLinesUp = 2620,
+ MoveSelectedLinesDown = 2621,
+ SetIdentifier = 2622,
+ GetIdentifier = 2623,
+ RGBAImageSetWidth = 2624,
+ RGBAImageSetHeight = 2625,
+ RGBAImageSetScale = 2651,
+ MarkerDefineRGBAImage = 2626,
+ RegisterRGBAImage = 2627,
+ ScrollToStart = 2628,
+ ScrollToEnd = 2629,
+ SetTechnology = 2630,
+ GetTechnology = 2631,
+ CreateLoader = 2632,
+ FindIndicatorShow = 2640,
+ FindIndicatorFlash = 2641,
+ FindIndicatorHide = 2642,
+ VCHomeDisplay = 2652,
+ VCHomeDisplayExtend = 2653,
+ GetCaretLineVisibleAlways = 2654,
+ SetCaretLineVisibleAlways = 2655,
+ SetLineEndTypesAllowed = 2656,
+ GetLineEndTypesAllowed = 2657,
+ GetLineEndTypesActive = 2658,
+ SetRepresentation = 2665,
+ GetRepresentation = 2666,
+ ClearRepresentation = 2667,
+ EOLAnnotationSetText = 2740,
+ EOLAnnotationGetText = 2741,
+ EOLAnnotationSetStyle = 2742,
+ EOLAnnotationGetStyle = 2743,
+ EOLAnnotationClearAll = 2744,
+ EOLAnnotationSetVisible = 2745,
+ EOLAnnotationGetVisible = 2746,
+ EOLAnnotationSetStyleOffset = 2747,
+ EOLAnnotationGetStyleOffset = 2748,
+ SupportsFeature = 2750,
+ GetLineCharacterIndex = 2710,
+ AllocateLineCharacterIndex = 2711,
+ ReleaseLineCharacterIndex = 2712,
+ LineFromIndexPosition = 2713,
+ IndexPositionFromLine = 2714,
+ StartRecord = 3001,
+ StopRecord = 3002,
+ GetLexer = 4002,
+ Colourise = 4003,
+ SetProperty = 4004,
+ SetKeyWords = 4005,
+ GetProperty = 4008,
+ GetPropertyExpanded = 4009,
+ GetPropertyInt = 4010,
+ GetLexerLanguage = 4012,
+ PrivateLexerCall = 4013,
+ PropertyNames = 4014,
+ PropertyType = 4015,
+ DescribeProperty = 4016,
+ DescribeKeyWordSets = 4017,
+ GetLineEndTypesSupported = 4018,
+ AllocateSubStyles = 4020,
+ GetSubStylesStart = 4021,
+ GetSubStylesLength = 4022,
+ GetStyleFromSubStyle = 4027,
+ GetPrimaryStyleFromStyle = 4028,
+ FreeSubStyles = 4023,
+ SetIdentifiers = 4024,
+ DistanceToSecondaryStyles = 4025,
+ GetSubStyleBases = 4026,
+ GetNamedStyles = 4029,
+ NameOfStyle = 4030,
+ TagsOfStyle = 4031,
+ DescriptionOfStyle = 4032,
+ SetILexer = 4033,
+ GetBidirectional = 2708,
+ SetBidirectional = 2709,
+};
+//--Autogenerated -- end of section automatically generated from Scintilla.iface
+
+}
+
+#endif
diff --git a/include/ScintillaStructures.h b/include/ScintillaStructures.h
new file mode 100644
index 000000000..6bd16e8c1
--- /dev/null
+++ b/include/ScintillaStructures.h
@@ -0,0 +1,103 @@
+// Scintilla source code edit control
+/** @file ScintillaStructures.h
+ ** Structures used to communicate with Scintilla.
+ ** The same structures are defined for C in Scintilla.h.
+ ** Uses definitions from ScintillaTypes.h.
+ **/
+// Copyright 2021 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef SCINTILLASTRUCTURES_H
+#define SCINTILLASTRUCTURES_H
+
+namespace Scintilla {
+
+using PositionCR = long;
+
+struct CharacterRange {
+ PositionCR cpMin;
+ PositionCR cpMax;
+};
+
+struct TextRange {
+ CharacterRange chrg;
+ char *lpstrText;
+};
+
+struct TextToFind {
+ CharacterRange chrg;
+ const char *lpstrText;
+ CharacterRange chrgText;
+};
+
+using SurfaceID = void *;
+
+struct Rectangle {
+ int left;
+ int top;
+ int right;
+ int bottom;
+};
+
+/* This structure is used in printing. Not needed by most client code. */
+
+struct RangeToFormat {
+ SurfaceID hdc;
+ SurfaceID hdcTarget;
+ Rectangle rc;
+ Rectangle rcPage;
+ CharacterRange chrg;
+};
+
+struct NotifyHeader {
+ /* Compatible with Windows NMHDR.
+ * hwndFrom is really an environment specific window handle or pointer
+ * but most clients of Scintilla.h do not have this type visible. */
+ void *hwndFrom;
+ uptr_t idFrom;
+ Notification code;
+};
+
+struct NotificationData {
+ NotifyHeader nmhdr;
+ Position position;
+ /* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, */
+ /* SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, */
+ /* SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, */
+ /* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */
+ /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */
+
+ int ch;
+ /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETED, SCN_AUTOCSELECTION, */
+ /* SCN_USERLISTSELECTION */
+ KeyMod modifiers;
+ /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */
+ /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */
+
+ ModificationFlags modificationType; /* SCN_MODIFIED */
+ const char *text;
+ /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */
+
+ Position length; /* SCN_MODIFIED */
+ Position linesAdded; /* SCN_MODIFIED */
+ Message message; /* SCN_MACRORECORD */
+ uptr_t wParam; /* SCN_MACRORECORD */
+ sptr_t lParam; /* SCN_MACRORECORD */
+ Position line; /* SCN_MODIFIED */
+ FoldLevel foldLevelNow; /* SCN_MODIFIED */
+ FoldLevel foldLevelPrev; /* SCN_MODIFIED */
+ int margin; /* SCN_MARGINCLICK */
+ int listType; /* SCN_USERLISTSELECTION */
+ int x; /* SCN_DWELLSTART, SCN_DWELLEND */
+ int y; /* SCN_DWELLSTART, SCN_DWELLEND */
+ int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */
+ Position annotationLinesAdded; /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */
+ Update updated; /* SCN_UPDATEUI */
+ CompletionMethods listCompletionMethod;
+ /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION, */
+ CharacterSource characterSource; /* SCN_CHARADDED */
+};
+
+}
+
+#endif
diff --git a/include/ScintillaTypes.h b/include/ScintillaTypes.h
new file mode 100644
index 000000000..6b5714b69
--- /dev/null
+++ b/include/ScintillaTypes.h
@@ -0,0 +1,786 @@
+// Scintilla source code edit control
+/** @file ScintillaTypes.h
+ ** Types used to communicate with Scintilla.
+ **/
+// Copyright 1998-2019 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+/* Most of this file is automatically generated from the Scintilla.iface interface definition
+ * file which contains any comments about the definitions. ScintillaAPIFacer.py does the generation. */
+
+#ifndef SCINTILLATYPES_H
+#define SCINTILLATYPES_H
+
+namespace Scintilla {
+
+// Enumerations
+//++Autogenerated -- start of section automatically generated from Scintilla.iface
+
+enum class WhiteSpace {
+ Invisible = 0,
+ VisibleAlways = 1,
+ VisibleAfterIndent = 2,
+ VisibleOnlyInIndent = 3,
+};
+
+enum class TabDrawMode {
+ LongArrow = 0,
+ StrikeOut = 1,
+};
+
+enum class EndOfLine {
+ CrLf = 0,
+ Cr = 1,
+ Lf = 2,
+};
+
+enum class IMEInteraction {
+ Windowed = 0,
+ Inline = 1,
+};
+
+enum class Alpha {
+ Transparent = 0,
+ Opaque = 255,
+ NoAlpha = 256,
+};
+
+enum class CursorShape {
+ Normal = -1,
+ Arrow = 2,
+ Wait = 4,
+ ReverseArrow = 7,
+};
+
+enum class MarkerSymbol {
+ Circle = 0,
+ RoundRect = 1,
+ Arrow = 2,
+ SmallRect = 3,
+ ShortArrow = 4,
+ Empty = 5,
+ ArrowDown = 6,
+ Minus = 7,
+ Plus = 8,
+ VLine = 9,
+ LCorner = 10,
+ TCorner = 11,
+ BoxPlus = 12,
+ BoxPlusConnected = 13,
+ BoxMinus = 14,
+ BoxMinusConnected = 15,
+ LCornerCurve = 16,
+ TCornerCurve = 17,
+ CirclePlus = 18,
+ CirclePlusConnected = 19,
+ CircleMinus = 20,
+ CircleMinusConnected = 21,
+ Background = 22,
+ DotDotDot = 23,
+ Arrows = 24,
+ Pixmap = 25,
+ FullRect = 26,
+ LeftRect = 27,
+ Available = 28,
+ Underline = 29,
+ RgbaImage = 30,
+ Bookmark = 31,
+ VerticalBookmark = 32,
+ Character = 10000,
+};
+
+enum class MarkerOutline {
+ FolderEnd = 25,
+ FolderOpenMid = 26,
+ FolderMidTail = 27,
+ FolderTail = 28,
+ FolderSub = 29,
+ Folder = 30,
+ FolderOpen = 31,
+};
+
+enum class MarginType {
+ Symbol = 0,
+ Number = 1,
+ Back = 2,
+ Fore = 3,
+ Text = 4,
+ RText = 5,
+ Colour = 6,
+};
+
+enum class StylesCommon {
+ Default = 32,
+ LineNumber = 33,
+ BraceLight = 34,
+ BraceBad = 35,
+ ControlChar = 36,
+ IndentGuide = 37,
+ CallTip = 38,
+ FoldDisplayText = 39,
+ LastPredefined = 39,
+ Max = 255,
+};
+
+enum class CharacterSet {
+ Ansi = 0,
+ Default = 1,
+ Baltic = 186,
+ ChineseBig5 = 136,
+ EastEurope = 238,
+ GB2312 = 134,
+ Greek = 161,
+ Hangul = 129,
+ Mac = 77,
+ Oem = 255,
+ Russian = 204,
+ Oem866 = 866,
+ Cyrillic = 1251,
+ ShiftJis = 128,
+ Symbol = 2,
+ Turkish = 162,
+ Johab = 130,
+ Hebrew = 177,
+ Arabic = 178,
+ Vietnamese = 163,
+ Thai = 222,
+ Iso8859_15 = 1000,
+};
+
+enum class CaseVisible {
+ Mixed = 0,
+ Upper = 1,
+ Lower = 2,
+ Camel = 3,
+};
+
+enum class FontWeight {
+ Normal = 400,
+ SemiBold = 600,
+ Bold = 700,
+};
+
+enum class Element {
+ List = 0,
+ ListBack = 1,
+ ListSelected = 2,
+ ListSelectedBack = 3,
+ SelectionText = 10,
+ SelectionBack = 11,
+ SelectionAdditionalText = 12,
+ SelectionAdditionalBack = 13,
+ SelectionSecondaryText = 14,
+ SelectionSecondaryBack = 15,
+ SelectionNoFocusText = 16,
+ SelectionNoFocusBack = 17,
+ Caret = 40,
+ CaretAdditional = 41,
+ CaretLineBack = 50,
+ WhiteSpace = 60,
+ WhiteSpaceBack = 61,
+ HotSpotActive = 70,
+ HotSpotActiveBack = 71,
+};
+
+enum class Layer {
+ Base = 0,
+ UnderText = 1,
+ OverText = 2,
+};
+
+enum class IndicatorStyle {
+ Plain = 0,
+ Squiggle = 1,
+ TT = 2,
+ Diagonal = 3,
+ Strike = 4,
+ Hidden = 5,
+ Box = 6,
+ RoundBox = 7,
+ StraightBox = 8,
+ Dash = 9,
+ Dots = 10,
+ SquiggleLow = 11,
+ DotBox = 12,
+ SquigglePixmap = 13,
+ CompositionThick = 14,
+ CompositionThin = 15,
+ FullBox = 16,
+ TextFore = 17,
+ Point = 18,
+ PointCharacter = 19,
+ Gradient = 20,
+ GradientCentre = 21,
+};
+
+enum class IndicatorNumbers {
+ Container = 8,
+ Ime = 32,
+ ImeMax = 35,
+ Max = 35,
+};
+
+enum class IndicValue {
+ Bit = 0x1000000,
+ Mask = 0xFFFFFF,
+};
+
+enum class IndicFlag {
+ None = 0,
+ ValueFore = 1,
+};
+
+enum class IndentView {
+ None = 0,
+ Real = 1,
+ LookForward = 2,
+ LookBoth = 3,
+};
+
+enum class PrintOption {
+ Normal = 0,
+ InvertLight = 1,
+ BlackOnWhite = 2,
+ ColourOnWhite = 3,
+ ColourOnWhiteDefaultBG = 4,
+ ScreenColours = 5,
+};
+
+enum class FindOption {
+ None = 0x0,
+ WholeWord = 0x2,
+ MatchCase = 0x4,
+ WordStart = 0x00100000,
+ RegExp = 0x00200000,
+ Posix = 0x00400000,
+ Cxx11RegEx = 0x00800000,
+};
+
+enum class FoldLevel {
+ None = 0x0,
+ Base = 0x400,
+ WhiteFlag = 0x1000,
+ HeaderFlag = 0x2000,
+ NumberMask = 0x0FFF,
+};
+
+enum class FoldDisplayTextStyle {
+ Hidden = 0,
+ Standard = 1,
+ Boxed = 2,
+};
+
+enum class FoldAction {
+ Contract = 0,
+ Expand = 1,
+ Toggle = 2,
+};
+
+enum class AutomaticFold {
+ None = 0x0000,
+ Show = 0x0001,
+ Click = 0x0002,
+ Change = 0x0004,
+};
+
+enum class FoldFlag {
+ None = 0x0000,
+ LineBeforeExpanded = 0x0002,
+ LineBeforeContracted = 0x0004,
+ LineAfterExpanded = 0x0008,
+ LineAfterContracted = 0x0010,
+ LevelNumbers = 0x0040,
+ LineState = 0x0080,
+};
+
+enum class IdleStyling {
+ None = 0,
+ ToVisible = 1,
+ AfterVisible = 2,
+ All = 3,
+};
+
+enum class Wrap {
+ None = 0,
+ Word = 1,
+ Char = 2,
+ WhiteSpace = 3,
+};
+
+enum class WrapVisualFlag {
+ None = 0x0000,
+ End = 0x0001,
+ Start = 0x0002,
+ Margin = 0x0004,
+};
+
+enum class WrapVisualLocation {
+ Default = 0x0000,
+ EndByText = 0x0001,
+ StartByText = 0x0002,
+};
+
+enum class WrapIndentMode {
+ Fixed = 0,
+ Same = 1,
+ Indent = 2,
+ DeepIndent = 3,
+};
+
+enum class LineCache {
+ None = 0,
+ Caret = 1,
+ Page = 2,
+ Document = 3,
+};
+
+enum class PhasesDraw {
+ One = 0,
+ Two = 1,
+ Multiple = 2,
+};
+
+enum class FontQuality {
+ QualityMask = 0xF,
+ QualityDefault = 0,
+ QualityNonAntialiased = 1,
+ QualityAntialiased = 2,
+ QualityLcdOptimized = 3,
+};
+
+enum class MultiPaste {
+ Once = 0,
+ Each = 1,
+};
+
+enum class Accessibility {
+ Disabled = 0,
+ Enabled = 1,
+};
+
+enum class EdgeVisualStyle {
+ None = 0,
+ Line = 1,
+ Background = 2,
+ MultiLine = 3,
+};
+
+enum class PopUp {
+ Never = 0,
+ All = 1,
+ Text = 2,
+};
+
+enum class DocumentOption {
+ Default = 0,
+ StylesNone = 0x1,
+ TextLarge = 0x100,
+};
+
+enum class Status {
+ Ok = 0,
+ Failure = 1,
+ BadAlloc = 2,
+ WarnStart = 1000,
+ RegEx = 1001,
+};
+
+enum class VisiblePolicy {
+ Slop = 0x01,
+ Strict = 0x04,
+};
+
+enum class CaretPolicy {
+ Slop = 0x01,
+ Strict = 0x04,
+ Jumps = 0x10,
+ Even = 0x08,
+};
+
+enum class SelectionMode {
+ Stream = 0,
+ Rectangle = 1,
+ Lines = 2,
+ Thin = 3,
+};
+
+enum class CaseInsensitiveBehaviour {
+ RespectCase = 0,
+ IgnoreCase = 1,
+};
+
+enum class MultiAutoComplete {
+ Once = 0,
+ Each = 1,
+};
+
+enum class Ordering {
+ PreSorted = 0,
+ PerformSort = 1,
+ Custom = 2,
+};
+
+enum class CaretSticky {
+ Off = 0,
+ On = 1,
+ WhiteSpace = 2,
+};
+
+enum class CaretStyle {
+ Invisible = 0,
+ Line = 1,
+ Block = 2,
+ OverstrikeBar = 0,
+ OverstrikeBlock = 0x10,
+ InsMask = 0xF,
+ BlockAfter = 0x100,
+};
+
+enum class MarginOption {
+ None = 0,
+ SubLineSelect = 1,
+};
+
+enum class AnnotationVisible {
+ Hidden = 0,
+ Standard = 1,
+ Boxed = 2,
+ Indented = 3,
+};
+
+enum class UndoFlags {
+ None = 0,
+ MayCoalesce = 1,
+};
+
+enum class VirtualSpace {
+ None = 0,
+ RectangularSelection = 1,
+ UserAccessible = 2,
+ NoWrapLineStart = 4,
+};
+
+enum class Technology {
+ Default = 0,
+ DirectWrite = 1,
+ DirectWriteRetain = 2,
+ DirectWriteDC = 3,
+};
+
+enum class LineEndType {
+ Default = 0,
+ Unicode = 1,
+};
+
+enum class EOLAnnotationVisible {
+ Hidden = 0x0,
+ Standard = 0x1,
+ Boxed = 0x2,
+ Stadium = 0x100,
+ FlatCircle = 0x101,
+ AngleCircle = 0x102,
+ CircleFlat = 0x110,
+ Flats = 0x111,
+ AngleFlat = 0x112,
+ CircleAngle = 0x120,
+ FlatAngle = 0x121,
+ Angles = 0x122,
+};
+
+enum class Supports {
+ LineDrawsFinal = 0,
+ PixelDivisions = 1,
+ FractionalStrokeWidth = 2,
+ TranslucentStroke = 3,
+ PixelModification = 4,
+};
+
+enum class LineCharacterIndexType {
+ None = 0,
+ Utf32 = 1,
+ Utf16 = 2,
+};
+
+enum class TypeProperty {
+ Boolean = 0,
+ Integer = 1,
+ String = 2,
+};
+
+enum class ModificationFlags {
+ None = 0x0,
+ InsertText = 0x1,
+ DeleteText = 0x2,
+ ChangeStyle = 0x4,
+ ChangeFold = 0x8,
+ User = 0x10,
+ Undo = 0x20,
+ Redo = 0x40,
+ MultiStepUndoRedo = 0x80,
+ LastStepInUndoRedo = 0x100,
+ ChangeMarker = 0x200,
+ BeforeInsert = 0x400,
+ BeforeDelete = 0x800,
+ MultilineUndoRedo = 0x1000,
+ StartAction = 0x2000,
+ ChangeIndicator = 0x4000,
+ ChangeLineState = 0x8000,
+ ChangeMargin = 0x10000,
+ ChangeAnnotation = 0x20000,
+ Container = 0x40000,
+ LexerState = 0x80000,
+ InsertCheck = 0x100000,
+ ChangeTabStops = 0x200000,
+ ChangeEOLAnnotation = 0x400000,
+ EventMaskAll = 0x7FFFFF,
+};
+
+enum class Update {
+ None = 0x0,
+ Content = 0x1,
+ Selection = 0x2,
+ VScroll = 0x4,
+ HScroll = 0x8,
+};
+
+enum class FocusChange {
+ Change = 768,
+ Setfocus = 512,
+ Killfocus = 256,
+};
+
+enum class Keys {
+ Down = 300,
+ Up = 301,
+ Left = 302,
+ Right = 303,
+ Home = 304,
+ End = 305,
+ Prior = 306,
+ Next = 307,
+ Delete = 308,
+ Insert = 309,
+ Escape = 7,
+ Back = 8,
+ Tab = 9,
+ Return = 13,
+ Add = 310,
+ Subtract = 311,
+ Divide = 312,
+ Win = 313,
+ RWin = 314,
+ Menu = 315,
+};
+
+enum class KeyMod {
+ Norm = 0,
+ Shift = 1,
+ Ctrl = 2,
+ Alt = 4,
+ Super = 8,
+ Meta = 16,
+};
+
+enum class CompletionMethods {
+ FillUp = 1,
+ DoubleClick = 2,
+ Tab = 3,
+ Newline = 4,
+ Command = 5,
+};
+
+enum class CharacterSource {
+ DirectInput = 0,
+ TentativeInput = 1,
+ ImeResult = 2,
+};
+
+enum class Bidirectional {
+ Disabled = 0,
+ L2R = 1,
+ R2L = 2,
+};
+
+enum class Notification {
+ StyleNeeded = 2000,
+ CharAdded = 2001,
+ SavePointReached = 2002,
+ SavePointLeft = 2003,
+ ModifyAttemptRO = 2004,
+ Key = 2005,
+ DoubleClick = 2006,
+ UpdateUI = 2007,
+ Modified = 2008,
+ MacroRecord = 2009,
+ MarginClick = 2010,
+ NeedShown = 2011,
+ Painted = 2013,
+ UserListSelection = 2014,
+ URIDropped = 2015,
+ DwellStart = 2016,
+ DwellEnd = 2017,
+ Zoom = 2018,
+ HotSpotClick = 2019,
+ HotSpotDoubleClick = 2020,
+ CallTipClick = 2021,
+ AutoCSelection = 2022,
+ IndicatorClick = 2023,
+ IndicatorRelease = 2024,
+ AutoCCancelled = 2025,
+ AutoCCharDeleted = 2026,
+ HotSpotReleaseClick = 2027,
+ FocusIn = 2028,
+ FocusOut = 2029,
+ AutoCCompleted = 2030,
+ MarginRightClick = 2031,
+ AutoCSelectionChange = 2032,
+};
+//--Autogenerated -- end of section automatically generated from Scintilla.iface
+
+using Position = intptr_t;
+using Line = intptr_t;
+using Colour = int;
+using ColourAlpha = int;
+using uptr_t = uintptr_t;
+using sptr_t = intptr_t;
+
+//++Autogenerated -- start of section automatically generated from Scintilla.iface
+//**1 \(\*\n\)
+constexpr Position InvalidPosition = -1;
+constexpr int CpUtf8 = 65001;
+constexpr int MarkerMax = 31;
+constexpr int MaskFolders = 0xFE000000;
+constexpr int MaxMargin = 4;
+constexpr int FontSizeMultiplier = 100;
+constexpr int TimeForever = 10000000;
+constexpr int KeywordsetMax = 8;
+
+//--Autogenerated -- end of section automatically generated from Scintilla.iface
+
+constexpr int IndicatorMax = static_cast<int>(IndicatorNumbers::Max);
+
+// Functions to manipulate fields from a MarkerOutline
+
+inline int operator<<(int i, MarkerOutline marker) noexcept {
+ return i << static_cast<int>(marker);
+}
+
+// Functions to manipulate fields from a FindOption
+
+constexpr FindOption operator|(FindOption a, FindOption b) noexcept {
+ return static_cast<FindOption>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline FindOption &operator|=(FindOption &self, FindOption a) noexcept {
+ self = self | a;
+ return self;
+}
+
+// Functions to retrieve and manipulate fields from a FoldLevel
+
+constexpr FoldLevel operator&(FoldLevel lhs, FoldLevel rhs) noexcept {
+ return static_cast<FoldLevel>(static_cast<int>(lhs) & static_cast<int>(rhs));
+}
+
+constexpr FoldLevel LevelNumberPart(FoldLevel level) noexcept {
+ return level & FoldLevel::NumberMask;
+}
+
+constexpr int LevelNumber(FoldLevel level) noexcept {
+ return static_cast<int>(LevelNumberPart(level));
+}
+
+constexpr bool LevelIsHeader(FoldLevel level) noexcept {
+ return (level & FoldLevel::HeaderFlag) == FoldLevel::HeaderFlag;
+}
+
+constexpr bool LevelIsWhitespace(FoldLevel level) noexcept {
+ return (level & FoldLevel::WhiteFlag) == FoldLevel::WhiteFlag;
+}
+
+// Functions to manipulate fields from a FoldFlag
+
+constexpr FoldFlag operator|(FoldFlag a, FoldFlag b) noexcept {
+ return static_cast<FoldFlag>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a FontQuality
+
+constexpr FontQuality operator&(FontQuality a, FontQuality b) noexcept {
+ return static_cast<FontQuality>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a DocumentOption
+
+constexpr DocumentOption operator|(DocumentOption a, DocumentOption b) noexcept {
+ return static_cast<DocumentOption>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a CaretPolicy
+
+constexpr CaretPolicy operator|(CaretPolicy a, CaretPolicy b) noexcept {
+ return static_cast<CaretPolicy>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a CaretStyle
+
+constexpr CaretStyle operator|(CaretStyle a, CaretStyle b) noexcept {
+ return static_cast<CaretStyle>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+constexpr CaretStyle operator&(CaretStyle a, CaretStyle b) noexcept {
+ return static_cast<CaretStyle>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a LineEndType
+
+constexpr LineEndType operator&(LineEndType a, LineEndType b) noexcept {
+ return static_cast<LineEndType>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a LineCharacterIndexType
+
+constexpr LineCharacterIndexType operator|(LineCharacterIndexType a, LineCharacterIndexType b) noexcept {
+ return static_cast<LineCharacterIndexType>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a ModificationFlags
+
+constexpr ModificationFlags operator|(ModificationFlags a, ModificationFlags b) noexcept {
+ return static_cast<ModificationFlags>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+constexpr ModificationFlags operator&(ModificationFlags a, ModificationFlags b) noexcept {
+ return static_cast<ModificationFlags>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+inline ModificationFlags &operator|=(ModificationFlags &self, ModificationFlags a) noexcept {
+ self = self | a;
+ return self;
+}
+
+// Functions to manipulate fields from a Update
+
+constexpr Update operator|(Update a, Update b) noexcept {
+ return static_cast<Update>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+// Functions to manipulate fields from a KeyMod
+
+constexpr KeyMod operator|(KeyMod a, KeyMod b) noexcept {
+ return static_cast<KeyMod>(static_cast<int>(a) | static_cast<int>(b));
+}
+
+constexpr KeyMod operator&(KeyMod a, KeyMod b) noexcept {
+ return static_cast<KeyMod>(static_cast<int>(a) & static_cast<int>(b));
+}
+
+// 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);
+}
+
+}
+
+#endif
diff --git a/qt/ScintillaEdit/ScintillaDocument.cpp b/qt/ScintillaEdit/ScintillaDocument.cpp
index 2272c383c..8d50eabdb 100644
--- a/qt/ScintillaEdit/ScintillaDocument.cpp
+++ b/qt/ScintillaEdit/ScintillaDocument.cpp
@@ -10,6 +10,9 @@
#include <optional>
#include <memory>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+#include "ScintillaStructures.h"
#include "ScintillaDocument.h"
#include "Debugging.h"
@@ -39,6 +42,7 @@
#include "Document.h"
using namespace Scintilla;
+using namespace Scintilla::Internal;
class WatcherHelper : public DocWatcher {
ScintillaDocument *owner;
@@ -52,7 +56,7 @@ public:
void NotifyDeleted(Document *doc, void *userData) noexcept override;
void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos) override;
void NotifyLexerChanged(Document *doc, void *userData) override;
- void NotifyErrorOccurred(Document *doc, void *userData, int status) override;
+ void NotifyErrorOccurred(Document *doc, void *userData, Status status) override;
};
WatcherHelper::WatcherHelper(ScintillaDocument *owner_) : owner(owner_) {
@@ -74,8 +78,8 @@ void WatcherHelper::NotifyModified(Document *, DocModification mh, void *) {
if (!mh.text)
length = 0;
QByteArray ba = QByteArray::fromRawData(mh.text, length);
- emit owner->modified(mh.position, mh.modificationType, ba, length,
- mh.linesAdded, mh.line, mh.foldLevelNow, mh.foldLevelPrev);
+ emit owner->modified(mh.position, static_cast<int>(mh.modificationType), ba, length,
+ mh.linesAdded, mh.line, static_cast<int>(mh.foldLevelNow), static_cast<int>(mh.foldLevelPrev));
}
void WatcherHelper::NotifyDeleted(Document *, void *) noexcept {
@@ -89,14 +93,14 @@ void WatcherHelper::NotifyLexerChanged(Document *, void *) {
emit owner->lexer_changed();
}
-void WatcherHelper::NotifyErrorOccurred(Document *, void *, int status) {
- emit owner->error_occurred(status);
+void WatcherHelper::NotifyErrorOccurred(Document *, void *, Status status) {
+ emit owner->error_occurred(static_cast<int>(status));
}
ScintillaDocument::ScintillaDocument(QObject *parent, void *pdoc_) :
QObject(parent), pdoc(pdoc_), docWatcher(nullptr) {
if (!pdoc) {
- pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);
+ pdoc = new Document(DocumentOption::Default);
}
docWatcher = new WatcherHelper(this);
(static_cast<Document *>(pdoc))->AddRef();
@@ -266,11 +270,11 @@ void ScintillaDocument::set_code_page(int code_page) {
}
int ScintillaDocument::get_eol_mode() {
- return (static_cast<Document *>(pdoc))->eolMode;
+ return static_cast<int>((static_cast<Document *>(pdoc))->eolMode);
}
void ScintillaDocument::set_eol_mode(int eol_mode) {
- (static_cast<Document *>(pdoc))->eolMode = eol_mode;
+ (static_cast<Document *>(pdoc))->eolMode = static_cast<EndOfLine>(eol_mode);
}
int ScintillaDocument::move_position_outside_char(int pos, int move_dir, bool check_line_end) {
diff --git a/qt/ScintillaEdit/ScintillaDocument.h b/qt/ScintillaEdit/ScintillaDocument.h
index c10d50d42..9a28689b6 100644
--- a/qt/ScintillaEdit/ScintillaDocument.h
+++ b/qt/ScintillaEdit/ScintillaDocument.h
@@ -80,7 +80,7 @@ signals:
void modify_attempt();
void save_point(bool atSavePoint);
void modified(int position, int modification_type, const QByteArray &text, int length,
- int linesAdded, int line, int foldLevelNow, int foldLevelPrev);
+ int linesAdded, int line, int foldLevelNow, int foldLevelPrev);
void style_needed(int pos);
void lexer_changed();
void error_occurred(int status);
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index d5475f4bd..2d49dcb5c 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -14,7 +14,6 @@
#include "Scintilla.h"
#include "UniConversion.h"
#include "DBCS.h"
-#include "FontQuality.h"
#include <QApplication>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
@@ -42,55 +41,57 @@
#include <QTextLine>
#include <QLibrary>
-namespace Scintilla {
+using namespace Scintilla;
+
+namespace Scintilla::Internal {
//----------------------------------------------------------------------
// Convert from a Scintilla characterSet value to a Qt codec name.
-const char *CharacterSetID(int characterSet)
+const char *CharacterSetID(CharacterSet characterSet)
{
switch (characterSet) {
- //case SC_CHARSET_ANSI:
+ //case CharacterSet::Ansi:
// return "";
- case SC_CHARSET_DEFAULT:
+ case CharacterSet::Default:
return "ISO 8859-1";
- case SC_CHARSET_BALTIC:
+ case CharacterSet::Baltic:
return "ISO 8859-13";
- case SC_CHARSET_CHINESEBIG5:
+ case CharacterSet::ChineseBig5:
return "Big5";
- case SC_CHARSET_EASTEUROPE:
+ case CharacterSet::EastEurope:
return "ISO 8859-2";
- case SC_CHARSET_GB2312:
+ case CharacterSet::GB2312:
return "GB18030-0";
- case SC_CHARSET_GREEK:
+ case CharacterSet::Greek:
return "ISO 8859-7";
- case SC_CHARSET_HANGUL:
+ case CharacterSet::Hangul:
return "CP949";
- case SC_CHARSET_MAC:
+ case CharacterSet::Mac:
return "Apple Roman";
//case SC_CHARSET_OEM:
// return "ASCII";
- case SC_CHARSET_RUSSIAN:
+ case CharacterSet::Russian:
return "KOI8-R";
- case SC_CHARSET_CYRILLIC:
+ case CharacterSet::Cyrillic:
return "Windows-1251";
- case SC_CHARSET_SHIFTJIS:
+ case CharacterSet::ShiftJis:
return "Shift-JIS";
//case SC_CHARSET_SYMBOL:
// return "";
- case SC_CHARSET_TURKISH:
+ case CharacterSet::Turkish:
return "ISO 8859-9";
//case SC_CHARSET_JOHAB:
// return "CP1361";
- case SC_CHARSET_HEBREW:
+ case CharacterSet::Hebrew:
return "ISO 8859-8";
- case SC_CHARSET_ARABIC:
+ case CharacterSet::Arabic:
return "ISO 8859-6";
- case SC_CHARSET_VIETNAMESE:
+ case CharacterSet::Vietnamese:
return "Windows-1258";
- case SC_CHARSET_THAI:
+ case CharacterSet::Thai:
return "TIS-620";
- case SC_CHARSET_8859_15:
+ case CharacterSet::Iso8859_15:
return "ISO 8859-15";
default:
return "ISO 8859-1";
@@ -101,27 +102,27 @@ QString UnicodeFromText(QTextCodec *codec, std::string_view text) {
return codec->toUnicode(text.data(), static_cast<int>(text.length()));
}
-static QFont::StyleStrategy ChooseStrategy(int eff)
+static QFont::StyleStrategy ChooseStrategy(FontQuality eff)
{
switch (eff) {
- case SC_EFF_QUALITY_DEFAULT: return QFont::PreferDefault;
- case SC_EFF_QUALITY_NON_ANTIALIASED: return QFont::NoAntialias;
- case SC_EFF_QUALITY_ANTIALIASED: return QFont::PreferAntialias;
- case SC_EFF_QUALITY_LCD_OPTIMIZED: return QFont::PreferAntialias;
+ case FontQuality::QualityDefault: return QFont::PreferDefault;
+ case FontQuality::QualityNonAntialiased: return QFont::NoAntialias;
+ case FontQuality::QualityAntialiased: return QFont::PreferAntialias;
+ case FontQuality::QualityLcdOptimized: return QFont::PreferAntialias;
default: return QFont::PreferDefault;
}
}
class FontAndCharacterSet : public Font {
public:
- int characterSet = 0;
+ CharacterSet characterSet = CharacterSet::Ansi;
QFont *pfont = nullptr;
FontAndCharacterSet(const FontParameters &fp) {
pfont = new QFont;
pfont->setStyleStrategy(ChooseStrategy(fp.extraFontFlag));
pfont->setFamily(QString::fromUtf8(fp.faceName));
pfont->setPointSizeF(fp.size);
- pfont->setBold(fp.weight > 500);
+ pfont->setBold(static_cast<int>(fp.weight) > 500);
pfont->setItalic(fp.italic);
characterSet = fp.characterSet;
@@ -134,11 +135,11 @@ public:
namespace {
-const int SupportsQt[] = {
- SC_SUPPORTS_LINE_DRAWS_FINAL,
- SC_SUPPORTS_FRACTIONAL_STROKE_WIDTH,
- SC_SUPPORTS_TRANSLUCENT_STROKE,
- SC_SUPPORTS_PIXEL_MODIFICATION,
+const Supports SupportsQt[] = {
+ Supports::LineDrawsFinal,
+ Supports::FractionalStrokeWidth,
+ Supports::TranslucentStroke,
+ Supports::PixelModification,
};
const FontAndCharacterSet *AsFontAndCharacterSet(const Font *f) {
@@ -216,9 +217,9 @@ void SurfaceImpl::Release() noexcept
Clear();
}
-int SurfaceImpl::Supports(int feature) noexcept
+int SurfaceImpl::SupportsFeature(Supports feature) noexcept
{
- for (const int f : SupportsQt) {
+ for (const Supports f : SupportsQt) {
if (f == feature)
return 1;
}
@@ -781,7 +782,7 @@ QPainter *SurfaceImpl::GetPainter()
return painter;
}
-std::unique_ptr<Surface> Surface::Allocate(int)
+std::unique_ptr<Surface> Surface::Allocate(Technology)
{
return std::make_unique<SurfaceImpl>();
}
@@ -942,7 +943,7 @@ public:
void SetFont(const Font *font) override;
void Create(Window &parent, int ctrlID, Point location,
- int lineHeight, bool unicodeMode_, int technology) override;
+ int lineHeight, bool unicodeMode_, Technology technology) override;
void SetAverageCharWidth(int width) override;
void SetVisibleRows(int rows) override;
int GetVisibleRows() const override;
@@ -979,7 +980,7 @@ void ListBoxImpl::Create(Window &parent,
Point location,
int /*lineHeight*/,
bool unicodeMode_,
- int)
+ Technology)
{
unicodeMode = unicodeMode_;
diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h
index 446e07ebb..02f3b0f7a 100644
--- a/qt/ScintillaEditBase/PlatQt.h
+++ b/qt/ScintillaEditBase/PlatQt.h
@@ -20,6 +20,8 @@
#include "Debugging.h"
#include "Geometry.h"
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
#include "Platform.h"
#include <QUrl>
@@ -27,9 +29,9 @@
#include <QPainter>
#include <QHash>
-namespace Scintilla {
+namespace Scintilla::Internal {
-const char *CharacterSetID(int characterSet);
+const char *CharacterSetID(Scintilla::CharacterSet characterSet);
inline QColor QColorFromColourRGBA(ColourRGBA ca)
{
@@ -89,7 +91,7 @@ public:
void SetMode(SurfaceMode mode) override;
void Release() noexcept override;
- int Supports(int feature) noexcept override;
+ int SupportsFeature(Scintilla::Supports feature) noexcept override;
bool Initialised() override;
void PenColour(ColourRGBA fore);
void PenColourWidth(ColourRGBA fore, XYPOSITION strokeWidth);
diff --git a/qt/ScintillaEditBase/ScintillaEditBase.cpp b/qt/ScintillaEditBase/ScintillaEditBase.cpp
index c94cd13f7..393910ba2 100644
--- a/qt/ScintillaEditBase/ScintillaEditBase.cpp
+++ b/qt/ScintillaEditBase/ScintillaEditBase.cpp
@@ -40,6 +40,7 @@
#endif // QT_VERSION >= 5.0.0
using namespace Scintilla;
+using namespace Scintilla::Internal;
ScintillaEditBase::ScintillaEditBase(QWidget *parent)
: QAbstractScrollArea(parent), sqt(nullptr), preeditPos(-1), wheelDelta(0)
@@ -59,10 +60,10 @@ ScintillaEditBase::ScintillaEditBase(QWidget *parent)
setAttribute(Qt::WA_KeyCompression);
setAttribute(Qt::WA_InputMethodEnabled);
- sqt->vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(INDIC_HIDDEN, ColourRGBA(0, 0, 0xff));
- sqt->vs.indicators[SC_INDICATOR_INPUT] = Indicator(INDIC_DOTS, ColourRGBA(0, 0, 0xff));
- sqt->vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(INDIC_COMPOSITIONTHICK, ColourRGBA(0, 0, 0xff));
- sqt->vs.indicators[SC_INDICATOR_TARGET] = Indicator(INDIC_STRAIGHTBOX, ColourRGBA(0, 0, 0xff));
+ sqt->vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(IndicatorStyle::Hidden, ColourRGBA(0, 0, 0xff));
+ sqt->vs.indicators[SC_INDICATOR_INPUT] = Indicator(IndicatorStyle::Dots, ColourRGBA(0, 0, 0xff));
+ sqt->vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(IndicatorStyle::CompositionThick, ColourRGBA(0, 0, 0xff));
+ sqt->vs.indicators[SC_INDICATOR_TARGET] = Indicator(IndicatorStyle::StraightBox, ColourRGBA(0, 0, 0xff));
connect(sqt, SIGNAL(notifyParent(SCNotification)),
this, SLOT(notifyParent(SCNotification)));
@@ -100,7 +101,7 @@ sptr_t ScintillaEditBase::send(
uptr_t wParam,
sptr_t lParam) const
{
- return sqt->WndProc(iMessage, wParam, lParam);
+ return sqt->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
sptr_t ScintillaEditBase::sends(
@@ -108,7 +109,7 @@ sptr_t ScintillaEditBase::sends(
uptr_t wParam,
const char *s) const
{
- return sqt->WndProc(iMessage, wParam, (sptr_t)s);
+ return sqt->WndProc(static_cast<Message>(iMessage), wParam, (sptr_t)s);
}
void ScintillaEditBase::scrollHorizontal(int value)
@@ -179,9 +180,9 @@ void ScintillaEditBase::wheelEvent(QWheelEvent *event)
// Zoom! We play with the font sizes in the styles.
// Number of steps/line is ignored, we just care if sizing up or down
if (wheelEventYDelta(event) > 0) {
- sqt->KeyCommand(SCI_ZOOMIN);
+ sqt->KeyCommand(Message::ZoomIn);
} else {
- sqt->KeyCommand(SCI_ZOOMOUT);
+ sqt->KeyCommand(Message::ZoomOut);
}
} else {
// Ignore wheel events when the scroll bars are disabled.
@@ -257,7 +258,7 @@ void ScintillaEditBase::keyPressEvent(QKeyEvent *event)
bool alt = QApplication::keyboardModifiers() & Qt::AltModifier;
bool consumed = false;
- bool added = sqt->KeyDownWithModifiers(key,
+ bool added = sqt->KeyDownWithModifiers(static_cast<Keys>(key),
ScintillaQt::ModifierFlags(shift, ctrl, alt),
&consumed) != 0;
if (!consumed)
@@ -278,7 +279,7 @@ void ScintillaEditBase::keyPressEvent(QKeyEvent *event)
QString text = event->text();
if (input && !text.isEmpty() && text[0].isPrint()) {
QByteArray utext = sqt->BytesForDocument(text);
- sqt->InsertCharacter(std::string_view(utext.data(), utext.size()), EditModel::CharacterSource::directInput);
+ sqt->InsertCharacter(std::string_view(utext.data(), utext.size()), CharacterSource::DirectInput);
} else {
event->ignore();
}
@@ -374,7 +375,7 @@ void ScintillaEditBase::mouseMoveEvent(QMouseEvent *event)
bool alt = QApplication::keyboardModifiers() & Qt::AltModifier;
#endif
- const int modifiers = ScintillaQt::ModifierFlags(shift, ctrl, alt);
+ const KeyMod modifiers = ScintillaQt::ModifierFlags(shift, ctrl, alt);
sqt->ButtonMoveWithModifiers(pos, time.elapsed(), modifiers);
}
@@ -568,7 +569,7 @@ void ScintillaEditBase::inputMethodEvent(QInputMethodEvent *event)
const QString oneCharUTF16 = commitStr.mid(i, ucWidth);
const QByteArray oneChar = sqt->BytesForDocument(oneCharUTF16);
- sqt->InsertCharacter(std::string_view(oneChar.data(), oneChar.length()), EditModel::CharacterSource::directInput);
+ sqt->InsertCharacter(std::string_view(oneChar.data(), oneChar.length()), CharacterSource::DirectInput);
i += ucWidth;
}
@@ -592,7 +593,7 @@ void ScintillaEditBase::inputMethodEvent(QInputMethodEvent *event)
const QByteArray oneChar = sqt->BytesForDocument(oneCharUTF16);
const int oneCharLen = oneChar.length();
- sqt->InsertCharacter(std::string_view(oneChar.data(), oneCharLen), EditModel::CharacterSource::tentativeInput);
+ sqt->InsertCharacter(std::string_view(oneChar.data(), oneCharLen), CharacterSource::TentativeInput);
DrawImeIndicator(imeIndicator[i], oneCharLen);
i += ucWidth;
@@ -832,7 +833,7 @@ void ScintillaEditBase::event_command(uptr_t wParam, sptr_t lParam)
emit command(wParam, lParam);
}
-int ScintillaEditBase::ModifiersOfKeyboard() const
+KeyMod ScintillaEditBase::ModifiersOfKeyboard() const
{
const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
const bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier;
diff --git a/qt/ScintillaEditBase/ScintillaEditBase.h b/qt/ScintillaEditBase/ScintillaEditBase.h
index a0375f13d..751b9d294 100644
--- a/qt/ScintillaEditBase/ScintillaEditBase.h
+++ b/qt/ScintillaEditBase/ScintillaEditBase.h
@@ -21,6 +21,9 @@
#include "Debugging.h"
#include "Geometry.h"
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+#include "ScintillaStructures.h"
#include "Platform.h"
#include "Scintilla.h"
@@ -28,7 +31,7 @@
#include <QMimeData>
#include <QElapsedTimer>
-namespace Scintilla {
+namespace Scintilla::Internal {
class ScintillaQt;
class SurfaceImpl;
@@ -146,7 +149,7 @@ protected:
void scrollContentsBy(int, int) override {}
private:
- Scintilla::ScintillaQt *sqt;
+ Scintilla::Internal::ScintillaQt *sqt;
QElapsedTimer time;
@@ -158,7 +161,7 @@ private:
static bool IsHangul(const QChar qchar);
void MoveImeCarets(int offset);
void DrawImeIndicator(int indicator, int len);
- int ModifiersOfKeyboard() const;
+ Scintilla::KeyMod ModifiersOfKeyboard() const;
};
#endif /* SCINTILLAEDITBASE_H */
diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp
index 710b7de9f..f90313554 100644
--- a/qt/ScintillaEditBase/ScintillaQt.cpp
+++ b/qt/ScintillaEditBase/ScintillaQt.cpp
@@ -23,7 +23,7 @@
#include <QTimer>
using namespace Scintilla;
-
+using namespace Scintilla::Internal;
ScintillaQt::ScintillaQt(QAbstractScrollArea *parent)
: QObject(parent), scrollArea(parent), vMax(0), hMax(0), vPage(0), hPage(0),
@@ -32,7 +32,7 @@ ScintillaQt::ScintillaQt(QAbstractScrollArea *parent)
wMain = scrollArea->viewport();
- imeInteraction = IMEInteraction::internal;
+ imeInteraction = IMEInteraction::Inline;
// On OS X drawing text into a pixmap moves it around 1 pixel to
// the right compared to drawing it directly onto a window.
@@ -385,7 +385,7 @@ void ScintillaQt::PasteFromMode(QClipboard::Mode clipboardMode_)
selText.Copy(dest, pdoc->dbcsCodePage, CharacterSetOfDocument(), isRectangular, false);
UndoGroup ug(pdoc);
- ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH);
+ ClearSelection(multiPasteMode == MultiPaste::Each);
InsertPasteShape(selText.Data(), selText.Length(),
isRectangular ? PasteShape::rectangular : (isLine ? PasteShape::line : PasteShape::stream));
EnsureCaretVisible();
@@ -432,7 +432,7 @@ void ScintillaQt::NotifyFocus(bool focus)
Editor::NotifyFocus(focus);
}
-void ScintillaQt::NotifyParent(SCNotification scn)
+void ScintillaQt::NotifyParent(NotificationData scn)
{
scn.nmhdr.hwndFrom = wMain.GetID();
scn.nmhdr.idFrom = GetCtrlID();
@@ -441,8 +441,8 @@ void ScintillaQt::NotifyParent(SCNotification scn)
void ScintillaQt::NotifyURIDropped(const char *uri)
{
- SCNotification scn = {};
- scn.nmhdr.code = SCN_URIDROPPED;
+ NotificationData scn = {};
+ scn.nmhdr.code = Notification::URIDropped;
scn.text = uri;
NotifyParent(scn);
@@ -519,7 +519,7 @@ bool ScintillaQt::SetIdle(bool on)
return ChangeIdle(on);
}
-int ScintillaQt::CharacterSetOfDocument() const
+CharacterSet ScintillaQt::CharacterSetOfDocument() const
{
return vs.styles[STYLE_DEFAULT].characterSet;
}
@@ -689,7 +689,7 @@ public:
void paintEvent(QPaintEvent *) override
{
if (pct->inCallTipMode) {
- std::unique_ptr<Surface> surfaceWindow = Surface::Allocate(0);
+ std::unique_ptr<Surface> surfaceWindow = Surface::Allocate(Technology::Default);
surfaceWindow->Init(this);
surfaceWindow->SetMode(SurfaceMode(pct->codePage, false));
pct->PaintCT(surfaceWindow.get());
@@ -732,37 +732,37 @@ void ScintillaQt::AddToPopUp(const char *label,
this, SLOT(execCommand(QAction *)));
}
-sptr_t ScintillaQt::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam)
+sptr_t ScintillaQt::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam)
{
try {
switch (iMessage) {
- case SCI_SETIMEINTERACTION:
+ case Message::SetIMEInteraction:
// Only inline IME supported on Qt
break;
- case SCI_GRABFOCUS:
+ case Message::GrabFocus:
scrollArea->setFocus(Qt::OtherFocusReason);
break;
- case SCI_GETDIRECTFUNCTION:
+ case Message::GetDirectFunction:
return reinterpret_cast<sptr_t>(DirectFunction);
- case SCI_GETDIRECTPOINTER:
+ case Message::GetDirectPointer:
return reinterpret_cast<sptr_t>(this);
default:
return ScintillaBase::WndProc(iMessage, wParam, lParam);
}
} catch (std::bad_alloc &) {
- errorStatus = SC_STATUS_BADALLOC;
+ errorStatus = Status::BadAlloc;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return 0;
}
-sptr_t ScintillaQt::DefWndProc(unsigned int, uptr_t, sptr_t)
+sptr_t ScintillaQt::DefWndProc(Message, uptr_t, sptr_t)
{
return 0;
}
@@ -770,7 +770,7 @@ sptr_t ScintillaQt::DefWndProc(unsigned int, uptr_t, sptr_t)
sptr_t ScintillaQt::DirectFunction(
sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam)
{
- return reinterpret_cast<ScintillaQt *>(ptr)->WndProc(iMessage, wParam, lParam);
+ return reinterpret_cast<ScintillaQt *>(ptr)->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
// Additions to merge in Scientific Toolworks widget structure
diff --git a/qt/ScintillaEditBase/ScintillaQt.h b/qt/ScintillaEditBase/ScintillaQt.h
index adbf11efd..053e59cc8 100644
--- a/qt/ScintillaEditBase/ScintillaQt.h
+++ b/qt/ScintillaEditBase/ScintillaQt.h
@@ -29,6 +29,9 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+#include "ScintillaStructures.h"
#include "Scintilla.h"
#include "Debugging.h"
#include "Geometry.h"
@@ -71,7 +74,7 @@
class ScintillaEditBase;
-namespace Scintilla {
+namespace Scintilla::Internal {
class ScintillaQt : public QObject, public ScintillaBase {
Q_OBJECT
@@ -86,14 +89,14 @@ signals:
void horizontalRangeChanged(int max, int page);
void verticalRangeChanged(int max, int page);
- void notifyParent(SCNotification scn);
+ void notifyParent(Scintilla::NotificationData scn);
void notifyChange();
// Clients can use this hook to add additional
// formats (e.g. rich text) to the MIME data.
void aboutToCopy(QMimeData *data);
- void command(uptr_t wParam, sptr_t lParam);
+ void command(Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
private slots:
void onIdle();
@@ -122,7 +125,7 @@ private:
void ClaimSelection() override;
void NotifyChange() override;
void NotifyFocus(bool focus) override;
- void NotifyParent(SCNotification scn) override;
+ void NotifyParent(Scintilla::NotificationData scn) override;
void NotifyURIDropped(const char *uri);
int timers[static_cast<size_t>(TickReason::dwell)+1];
bool FineTickerRunning(TickReason reason) override;
@@ -134,7 +137,7 @@ private:
void SetMouseCapture(bool on) override;
bool HaveMouseCapture() override;
void StartDrag() override;
- int CharacterSetOfDocument() const;
+ Scintilla::CharacterSet CharacterSetOfDocument() const;
const char *CharacterSetIDOfDocument() const;
QString StringFromDocument(const char *s) const;
QByteArray BytesForDocument(const QString &text) const;
@@ -143,8 +146,8 @@ private:
void CreateCallTipWindow(PRectangle rc) override;
void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override;
- sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
- sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t WndProc(Scintilla::Message iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t DefWndProc(Scintilla::Message iMessage, uptr_t wParam, sptr_t lParam) override;
static sptr_t DirectFunction(sptr_t ptr,
unsigned int iMessage, uptr_t wParam, sptr_t lParam);
diff --git a/scripts/Face.py b/scripts/Face.py
index 94451bc26..1559dfccd 100644
--- a/scripts/Face.py
+++ b/scripts/Face.py
@@ -41,6 +41,23 @@ def decodeParam(p):
def IsEnumeration(t):
return t[:1].isupper()
+def PascalCase(s):
+ capitalized = s.title()
+ # Remove '_' except between digits
+ pascalCase = ""
+ characterPrevious = " "
+ # Loop until penultimate character
+ for i in range(len(capitalized)-1):
+ character = capitalized[i]
+ characterNext = capitalized[i+1]
+ if character != "_" or (
+ characterPrevious.isnumeric() and characterNext.isnumeric()):
+ pascalCase += character
+ characterPrevious = character
+ # Add last character - not between digits so no special treatment
+ pascalCase += capitalized[-1]
+ return pascalCase
+
class Face:
def __init__(self):
diff --git a/scripts/HeaderOrder.txt b/scripts/HeaderOrder.txt
index 72ee15cb1..6d953af8f 100644
--- a/scripts/HeaderOrder.txt
+++ b/scripts/HeaderOrder.txt
@@ -90,14 +90,20 @@
// Non-platform-specific headers
+// Exported headers
+
+#include "Sci_Position.h"
+#include "ScintillaTypes.h"
+#include "ScintillaMessages.h"
+#include "ScintillaStructures.h"
+#include "ILoader.h"
+#include "ILexer.h"
+
// src platform interface
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Sci_Position.h"
-#include "ILoader.h"
-#include "ILexer.h"
#include "Scintilla.h"
#include "ScintillaWidget.h"
@@ -130,7 +136,6 @@
#include "DBCS.h"
#include "Selection.h"
#include "PositionCache.h"
-#include "FontQuality.h"
#include "EditModel.h"
#include "MarginView.h"
#include "EditView.h"
diff --git a/scripts/ScintillaAPIFacer.py b/scripts/ScintillaAPIFacer.py
new file mode 100644
index 000000000..1d8463f18
--- /dev/null
+++ b/scripts/ScintillaAPIFacer.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python3
+# ScintillaAPIFacer.py - regenerate the ScintillaTypes.h, and ScintillaMessages.h
+# from the Scintilla.iface interface definition file.
+# Implemented 2019 by Neil Hodgson neilh@scintilla.org
+# Requires Python 3.6 or later
+
+import Face
+import FileGenerator
+
+def HMessages(f):
+ out = ["enum class Message {"]
+ for name in f.order:
+ v = f.features[name]
+ if v["Category"] != "Deprecated":
+ if v["FeatureType"] in ["fun", "get", "set"]:
+ out.append("\t" + name + " = " + v["Value"] + ",")
+ out.append("};")
+ return out
+
+deadValues = [
+ "INDIC_CONTAINER",
+ "INDIC_IME",
+ "INDIC_IME_MAX",
+ "INDIC_MAX",
+]
+
+def HEnumerations(f):
+ out = []
+ for name in f.order:
+ v = f.features[name]
+ if v["Category"] != "Deprecated":
+ # Only want non-deprecated enumerations and lexers are not part of Scintilla API
+ if v["FeatureType"] in ["enu"] and name != "Lexer":
+ out.append("")
+ prefixes = v["Value"].split()
+ #out.append("enum class " + name + " {" + " // " + ",".join(prefixes))
+ out.append("enum class " + name + " {")
+ for valueName in f.order:
+ prefixMatched = ""
+ for p in prefixes:
+ if valueName.startswith(p) and valueName not in deadValues:
+ prefixMatched = p
+ if prefixMatched:
+ vEnum = f.features[valueName]
+ valueNameNoPrefix = ""
+ if valueName in f.aliases:
+ valueNameNoPrefix = f.aliases[valueName]
+ else:
+ valueNameNoPrefix = valueName[len(prefixMatched):]
+ if not valueNameNoPrefix: # Removed whole name
+ valueNameNoPrefix = valueName
+ if valueNameNoPrefix.startswith("SC_"):
+ valueNameNoPrefix = valueNameNoPrefix[len("SC_"):]
+ pascalName = Face.PascalCase(valueNameNoPrefix)
+ out.append("\t" + pascalName + " = " + vEnum["Value"] + ",")
+ out.append("};")
+
+ out.append("")
+ out.append("enum class Notification {")
+ for name in f.order:
+ v = f.features[name]
+ if v["Category"] != "Deprecated":
+ if v["FeatureType"] in ["evt"]:
+ out.append("\t" + name + " = " + v["Value"] + ",")
+ out.append("};")
+
+ return out
+
+def HConstants(f):
+ # Constants not in an eumeration
+ out = []
+ allEnumPrefixes = [
+ "SCE_", # Lexical styles
+ "SCI_", # Message number allocation
+ "SCEN_", # Notifications sent with WM_COMMAND
+ ]
+ for _n, v in f.features.items():
+ if v["Category"] != "Deprecated":
+ # Only want non-deprecated enumerations and lexers are not part of Scintilla API
+ if v["FeatureType"] in ["enu"]:
+ allEnumPrefixes.extend(v["Value"].split())
+ for name in f.order:
+ v = f.features[name]
+ if v["Category"] != "Deprecated":
+ # Only want non-deprecated enumerations and lexers are not part of Scintilla API
+ if v["FeatureType"] in ["val"]:
+ hasPrefix = False
+ for prefix in allEnumPrefixes:
+ if name.startswith(prefix):
+ hasPrefix = True
+ if not hasPrefix:
+ if name.startswith("SC_"):
+ name = name[3:]
+ type = "int"
+ if name == "INVALID_POSITION":
+ type = "Position"
+ out.append("constexpr " + type + " " + Face.PascalCase(name) + " = " + v["Value"] + ";")
+ return out
+
+def RegenerateAll(root):
+ f = Face.Face()
+ f.ReadFromFile(root + "include/Scintilla.iface")
+ FileGenerator.Regenerate(root + "include/ScintillaMessages.h", "//", HMessages(f))
+ FileGenerator.Regenerate(root + "include/ScintillaTypes.h", "//", HEnumerations(f), HConstants(f))
+
+if __name__ == "__main__":
+ RegenerateAll("../")
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.
diff --git a/test/unit/UnitTester.cxx b/test/unit/UnitTester.cxx
index d83a803b5..e498add10 100644
--- a/test/unit/UnitTester.cxx
+++ b/test/unit/UnitTester.cxx
@@ -20,7 +20,7 @@
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Needed for PLATFORM_ASSERT in code being tested
diff --git a/test/unit/testCellBuffer.cxx b/test/unit/testCellBuffer.cxx
index 22f8a616c..b48e44bb9 100644
--- a/test/unit/testCellBuffer.cxx
+++ b/test/unit/testCellBuffer.cxx
@@ -11,9 +11,10 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
-#include "Scintilla.h"
#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
@@ -23,6 +24,7 @@
#include "catch.hpp"
using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test CellBuffer.
@@ -132,11 +134,11 @@ TEST_CASE("CellBuffer") {
}
SECTION("LineEndTypes") {
- REQUIRE(cb.GetLineEndTypes() == 0);
- cb.SetLineEndTypes(1);
- REQUIRE(cb.GetLineEndTypes() == 1);
- cb.SetLineEndTypes(0);
- REQUIRE(cb.GetLineEndTypes() == 0);
+ REQUIRE(cb.GetLineEndTypes() == LineEndType::Default);
+ cb.SetLineEndTypes(LineEndType::Unicode);
+ REQUIRE(cb.GetLineEndTypes() == LineEndType::Unicode);
+ cb.SetLineEndTypes(LineEndType::Default);
+ REQUIRE(cb.GetLineEndTypes() == LineEndType::Default);
}
SECTION("ReadOnly") {
@@ -155,122 +157,122 @@ TEST_CASE("CharacterIndex") {
CellBuffer cb(true, false);
SECTION("Setup") {
- REQUIRE(cb.LineCharacterIndex() == SC_LINECHARACTERINDEX_NONE);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 0);
+ REQUIRE(cb.LineCharacterIndex() == LineCharacterIndexType::None);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 0);
cb.SetUTF8Substance(true);
- cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16);
- REQUIRE(cb.LineCharacterIndex() == SC_LINECHARACTERINDEX_UTF16);
+ cb.AllocateLineCharacterIndex(LineCharacterIndexType::Utf16);
+ REQUIRE(cb.LineCharacterIndex() == LineCharacterIndexType::Utf16);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 0);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 0);
- cb.ReleaseLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16);
- REQUIRE(cb.LineCharacterIndex() == SC_LINECHARACTERINDEX_NONE);
+ cb.ReleaseLineCharacterIndex(LineCharacterIndexType::Utf16);
+ REQUIRE(cb.LineCharacterIndex() == LineCharacterIndexType::None);
}
SECTION("Insertion") {
cb.SetUTF8Substance(true);
- cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32);
+ cb.AllocateLineCharacterIndex(LineCharacterIndexType::Utf16 | LineCharacterIndexType::Utf32);
bool startSequence = false;
cb.InsertString(0, "a", 1, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 1);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 1);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 1);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 1);
const char *hwair = "\xF0\x90\x8D\x88";
cb.InsertString(0, hwair, strlen(hwair), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 3);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 2);
}
SECTION("Deletion") {
cb.SetUTF8Substance(true);
- cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32);
+ cb.AllocateLineCharacterIndex(LineCharacterIndexType::Utf16 | LineCharacterIndexType::Utf32);
bool startSequence = false;
const char *hwair = "a\xF0\x90\x8D\x88z";
cb.InsertString(0, hwair, strlen(hwair), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 4);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 4);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 3);
cb.DeleteChars(5, 1, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 3);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 2);
cb.DeleteChars(1, 4, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 1);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 1);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 1);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 1);
}
SECTION("Insert Complex") {
cb.SetUTF8Substance(true);
- cb.SetLineEndTypes(1);
- cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32);
+ cb.SetLineEndTypes(LineEndType::Unicode);
+ cb.AllocateLineCharacterIndex(LineCharacterIndexType::Utf16 | LineCharacterIndexType::Utf32);
bool startSequence = false;
// 3 lines of text containing 8 bytes
const char *data = "a\n\xF0\x90\x8D\x88\nz";
cb.InsertString(0, data, strlen(data), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 6);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 5);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 6);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 5);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 4);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf32) == 5);
// Insert a new line at end -> "a\n\xF0\x90\x8D\x88\nz\n" 4 lines
// Last line empty
cb.InsertString(strlen(data), "\n", 1, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 7);
- REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF16) == 7);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 5);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 7);
+ REQUIRE(cb.IndexLineStart(4, LineCharacterIndexType::Utf16) == 7);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 6);
- REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF32) == 6);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 4);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf32) == 6);
+ REQUIRE(cb.IndexLineStart(4, LineCharacterIndexType::Utf32) == 6);
// Insert a new line before end -> "a\n\xF0\x90\x8D\x88\nz\n\n" 5 lines
cb.InsertString(strlen(data), "\n", 1, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 7);
- REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF16) == 8);
- REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF16) == 8);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 5);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 7);
+ REQUIRE(cb.IndexLineStart(4, LineCharacterIndexType::Utf16) == 8);
+ REQUIRE(cb.IndexLineStart(5, LineCharacterIndexType::Utf16) == 8);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 6);
- REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF32) == 7);
- REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF32) == 7);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 4);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf32) == 6);
+ REQUIRE(cb.IndexLineStart(4, LineCharacterIndexType::Utf32) == 7);
+ REQUIRE(cb.IndexLineStart(5, LineCharacterIndexType::Utf32) == 7);
// Insert a valid 3-byte UTF-8 character at start ->
// "\xE2\x82\xACa\n\xF0\x90\x8D\x88\nz\n\n" 5 lines
@@ -278,19 +280,19 @@ TEST_CASE("CharacterIndex") {
const char *euro = "\xE2\x82\xAC";
cb.InsertString(0, euro, strlen(euro), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 6);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 8);
- REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF16) == 9);
- REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF16) == 9);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 6);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 8);
+ REQUIRE(cb.IndexLineStart(4, LineCharacterIndexType::Utf16) == 9);
+ REQUIRE(cb.IndexLineStart(5, LineCharacterIndexType::Utf16) == 9);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 5);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 7);
- REQUIRE(cb.IndexLineStart(4, SC_LINECHARACTERINDEX_UTF32) == 8);
- REQUIRE(cb.IndexLineStart(5, SC_LINECHARACTERINDEX_UTF32) == 8);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 5);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf32) == 7);
+ REQUIRE(cb.IndexLineStart(4, LineCharacterIndexType::Utf32) == 8);
+ REQUIRE(cb.IndexLineStart(5, LineCharacterIndexType::Utf32) == 8);
// Insert a lone lead byte implying a 3 byte character at start of line 2 ->
// "\xE2\x82\xACa\n\EF\xF0\x90\x8D\x88\nz\n\n" 5 lines
@@ -299,15 +301,15 @@ TEST_CASE("CharacterIndex") {
const char *lead = "\xEF";
cb.InsertString(5, lead, strlen(lead), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 7);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 9);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 7);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 9);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 6);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 8);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 6);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf32) == 8);
// Insert an ASCII lead byte inside the 3-byte initial character ->
// "\xE2!\x82\xACa\n\EF\xF0\x90\x8D\x88\nz\n\n" 5 lines
@@ -318,13 +320,13 @@ TEST_CASE("CharacterIndex") {
const char *ascii = "!";
cb.InsertString(1, ascii, strlen(ascii), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 6);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 10);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 6);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 10);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 6);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 9);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 6);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 9);
// Insert a NEL after the '!' to trigger the utf8 line end case ->
// "\xE2!\xC2\x85 \x82\xACa\n \EF\xF0\x90\x8D\x88\n z\n\n" 5 lines
@@ -332,20 +334,20 @@ TEST_CASE("CharacterIndex") {
const char *nel = "\xC2\x85";
cb.InsertString(2, nel, strlen(nel), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 7);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 11);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 7);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 11);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 7);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 10);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 7);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf32) == 10);
}
SECTION("Delete Multiple lines") {
cb.SetUTF8Substance(true);
- cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32);
+ cb.AllocateLineCharacterIndex(LineCharacterIndexType::Utf16 | LineCharacterIndexType::Utf32);
bool startSequence = false;
// 3 lines of text containing 8 bytes
@@ -355,18 +357,18 @@ TEST_CASE("CharacterIndex") {
// Delete first 2 new lines -> "az\nc"
cb.DeleteChars(1, strlen(data) - 4, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 4);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 4);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 4);
}
SECTION("Delete Complex") {
cb.SetUTF8Substance(true);
- cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32);
+ cb.AllocateLineCharacterIndex(LineCharacterIndexType::Utf16 | LineCharacterIndexType::Utf32);
bool startSequence = false;
// 3 lines of text containing 8 bytes
@@ -378,28 +380,28 @@ TEST_CASE("CharacterIndex") {
// line 1 becomes 4 single byte characters
cb.DeleteChars(2, 1, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 6);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 7);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 6);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 7);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 6);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF32) == 7);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 6);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf32) == 7);
// Delete first new line ->
// "a\x90\x8D\x88\nz"
// Only 2 lines with line 0 containing 5 single byte characters
cb.DeleteChars(1, 1, startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 5);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 6);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 5);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 6);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 5);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 6);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 5);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 6);
// Restore lead byte from character on line 0 making a 4-byte character ->
// "a\xF0\x90\x8D\x88\nz"
@@ -407,18 +409,18 @@ TEST_CASE("CharacterIndex") {
const char *lead4 = "\xF0";
cb.InsertString(1, lead4, strlen(lead4), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 4);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 5);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 4);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 5);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF32) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF32) == 3);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF32) == 4);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf32) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf32) == 3);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf32) == 4);
}
SECTION("Insert separates new line bytes") {
cb.SetUTF8Substance(true);
- cb.AllocateLineCharacterIndex(SC_LINECHARACTERINDEX_UTF16 | SC_LINECHARACTERINDEX_UTF32);
+ cb.AllocateLineCharacterIndex(LineCharacterIndexType::Utf16 | LineCharacterIndexType::Utf32);
bool startSequence = false;
// 2 lines of text containing 4 bytes
@@ -430,9 +432,9 @@ TEST_CASE("CharacterIndex") {
const char *ascii = "!";
cb.InsertString(2, ascii, strlen(ascii), startSequence);
- REQUIRE(cb.IndexLineStart(0, SC_LINECHARACTERINDEX_UTF16) == 0);
- REQUIRE(cb.IndexLineStart(1, SC_LINECHARACTERINDEX_UTF16) == 2);
- REQUIRE(cb.IndexLineStart(2, SC_LINECHARACTERINDEX_UTF16) == 4);
- REQUIRE(cb.IndexLineStart(3, SC_LINECHARACTERINDEX_UTF16) == 5);
+ REQUIRE(cb.IndexLineStart(0, LineCharacterIndexType::Utf16) == 0);
+ REQUIRE(cb.IndexLineStart(1, LineCharacterIndexType::Utf16) == 2);
+ REQUIRE(cb.IndexLineStart(2, LineCharacterIndexType::Utf16) == 4);
+ REQUIRE(cb.IndexLineStart(3, LineCharacterIndexType::Utf16) == 5);
}
}
diff --git a/test/unit/testCharClassify.cxx b/test/unit/testCharClassify.cxx
index 185681c5b..0dd75c514 100644
--- a/test/unit/testCharClassify.cxx
+++ b/test/unit/testCharClassify.cxx
@@ -17,7 +17,7 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test CharClassify.
diff --git a/test/unit/testContractionState.cxx b/test/unit/testContractionState.cxx
index 91672fe27..64f300a87 100644
--- a/test/unit/testContractionState.cxx
+++ b/test/unit/testContractionState.cxx
@@ -23,7 +23,7 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test ContractionState.
diff --git a/test/unit/testDecoration.cxx b/test/unit/testDecoration.cxx
index bd0b1cd58..023b44163 100644
--- a/test/unit/testDecoration.cxx
+++ b/test/unit/testDecoration.cxx
@@ -24,7 +24,7 @@
const int indicator=4;
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test Decoration.
diff --git a/test/unit/testPartitioning.cxx b/test/unit/testPartitioning.cxx
index fb70380e9..e28ef318e 100644
--- a/test/unit/testPartitioning.cxx
+++ b/test/unit/testPartitioning.cxx
@@ -20,7 +20,7 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
const int growSize = 4;
diff --git a/test/unit/testPerLine.cxx b/test/unit/testPerLine.cxx
index 669a047db..5209c194e 100644
--- a/test/unit/testPerLine.cxx
+++ b/test/unit/testPerLine.cxx
@@ -12,9 +12,10 @@
#include <algorithm>
#include <memory>
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
-#include "Scintilla.h"
#include "Position.h"
#include "SplitVector.h"
#include "Partitioning.h"
@@ -24,7 +25,9 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
+
+constexpr int FoldBase = static_cast<int>(Scintilla::FoldLevel::Base);
// Test MarkerHandleSet.
@@ -170,41 +173,41 @@ TEST_CASE("LineLevels") {
SECTION("Initial") {
// Initial State
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(0));
+ REQUIRE(FoldBase == ll.GetLevel(0));
}
SECTION("SetLevel") {
- REQUIRE(SC_FOLDLEVELBASE == ll.SetLevel(1, 200, 5));
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(0));
+ REQUIRE(FoldBase == ll.SetLevel(1, 200, 5));
+ REQUIRE(FoldBase == ll.GetLevel(0));
REQUIRE(200 == ll.GetLevel(1));
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(2));
+ REQUIRE(FoldBase == ll.GetLevel(2));
ll.ClearLevels();
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(1));
+ REQUIRE(FoldBase == ll.GetLevel(1));
ll.ExpandLevels(5);
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(7));
+ REQUIRE(FoldBase == ll.GetLevel(7));
}
SECTION("InsertRemoveLine") {
ll.SetLevel(1, 1, 5);
ll.SetLevel(2, 2, 5);
ll.InsertLine(2);
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(0));
+ REQUIRE(FoldBase == ll.GetLevel(0));
REQUIRE(1 == ll.GetLevel(1));
REQUIRE(2 == ll.GetLevel(2));
REQUIRE(2 == ll.GetLevel(3));
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(4));
+ REQUIRE(FoldBase == ll.GetLevel(4));
ll.RemoveLine(2);
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(0));
+ REQUIRE(FoldBase == ll.GetLevel(0));
REQUIRE(1 == ll.GetLevel(1));
REQUIRE(2 == ll.GetLevel(2));
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(3));
+ REQUIRE(FoldBase == ll.GetLevel(3));
ll.InsertLines(2, 2);
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(0));
+ REQUIRE(FoldBase == ll.GetLevel(0));
REQUIRE(1 == ll.GetLevel(1));
REQUIRE(2 == ll.GetLevel(2));
REQUIRE(2 == ll.GetLevel(3));
REQUIRE(2 == ll.GetLevel(4));
- REQUIRE(SC_FOLDLEVELBASE == ll.GetLevel(5));
+ REQUIRE(FoldBase == ll.GetLevel(5));
}
}
diff --git a/test/unit/testRunStyles.cxx b/test/unit/testRunStyles.cxx
index 43d9d5b0f..92e6b9ae8 100644
--- a/test/unit/testRunStyles.cxx
+++ b/test/unit/testRunStyles.cxx
@@ -21,11 +21,11 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test RunStyles.
-namespace Scintilla { // Xcode clang 9.0 doesn't like this when in the unnamed namespace
+namespace Scintilla::Internal { // Xcode clang 9.0 doesn't like this when in the unnamed namespace
bool operator==(const FillResult<int> &fra, const FillResult<int> &frb) {
return fra.changed == frb.changed &&
fra.position == frb.position &&
diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx
index ce84fb8da..0bc8f9093 100644
--- a/test/unit/testSparseVector.cxx
+++ b/test/unit/testSparseVector.cxx
@@ -23,7 +23,7 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test SparseVector.
diff --git a/test/unit/testSplitVector.cxx b/test/unit/testSplitVector.cxx
index 3f5cec3c5..8320d5bcb 100644
--- a/test/unit/testSplitVector.cxx
+++ b/test/unit/testSplitVector.cxx
@@ -19,7 +19,7 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test SplitVector.
diff --git a/test/unit/testUniConversion.cxx b/test/unit/testUniConversion.cxx
index 7bbf808ad..eabb46442 100644
--- a/test/unit/testUniConversion.cxx
+++ b/test/unit/testUniConversion.cxx
@@ -17,7 +17,7 @@
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Test UniConversion.
// Use examples from Wikipedia:
diff --git a/test/unit/unitTest.cxx b/test/unit/unitTest.cxx
index 8bcc570ac..c629b6b5d 100644
--- a/test/unit/unitTest.cxx
+++ b/test/unit/unitTest.cxx
@@ -56,7 +56,7 @@
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
-using namespace Scintilla;
+using namespace Scintilla::Internal;
// Needed for PLATFORM_ASSERT in code being tested
diff --git a/win32/HanjaDic.cxx b/win32/HanjaDic.cxx
index 805fc3641..bb9d2bf60 100644
--- a/win32/HanjaDic.cxx
+++ b/win32/HanjaDic.cxx
@@ -14,7 +14,7 @@
#include "UniConversion.h"
#include "HanjaDic.h"
-namespace Scintilla {
+namespace Scintilla::Internal {
namespace HanjaDict {
diff --git a/win32/HanjaDic.h b/win32/HanjaDic.h
index 3aafdf8ed..c23abc19a 100644
--- a/win32/HanjaDic.h
+++ b/win32/HanjaDic.h
@@ -9,7 +9,7 @@
#ifndef HANJADIC_H
#define HANJADIC_H
-namespace Scintilla {
+namespace Scintilla::Internal {
namespace HanjaDict {
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 8aaf610f6..f8bd7f163 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -45,14 +45,14 @@
#include <dwrite.h>
#endif
+#include "ScintillaTypes.h"
+
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
-#include "Scintilla.h"
#include "XPM.h"
#include "UniConversion.h"
#include "DBCS.h"
-#include "FontQuality.h"
#include "PlatWin.h"
@@ -69,9 +69,11 @@
#pragma clang diagnostic ignored "-Wlanguage-extension-token"
#endif
-namespace Scintilla {
+using namespace Scintilla;
+
+namespace Scintilla::Internal {
-UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) noexcept;
+UINT CodePageFromCharSet(CharacterSet characterSet, UINT documentCodePage) noexcept;
#if defined(USE_D2D)
IDWriteFactory *pIDWriteFactory = nullptr;
@@ -211,38 +213,38 @@ void LoadDpiForWindow() noexcept {
HINSTANCE hinstPlatformRes {};
-const int SupportsGDI[] = {
- SC_SUPPORTS_PIXEL_MODIFICATION,
+const Supports SupportsGDI[] = {
+ Supports::PixelModification,
};
-constexpr BYTE Win32MapFontQuality(int extraFontFlag) noexcept {
- switch (extraFontFlag & SC_EFF_QUALITY_MASK) {
+constexpr BYTE Win32MapFontQuality(FontQuality extraFontFlag) noexcept {
+ switch (extraFontFlag & FontQuality::QualityMask) {
- case SC_EFF_QUALITY_NON_ANTIALIASED:
+ case FontQuality::QualityNonAntialiased:
return NONANTIALIASED_QUALITY;
- case SC_EFF_QUALITY_ANTIALIASED:
+ case FontQuality::QualityAntialiased:
return ANTIALIASED_QUALITY;
- case SC_EFF_QUALITY_LCD_OPTIMIZED:
+ case FontQuality::QualityLcdOptimized:
return CLEARTYPE_QUALITY;
default:
- return SC_EFF_QUALITY_DEFAULT;
+ return DEFAULT_QUALITY;
}
}
#if defined(USE_D2D)
-constexpr D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) noexcept {
- switch (extraFontFlag & SC_EFF_QUALITY_MASK) {
+constexpr D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(FontQuality extraFontFlag) noexcept {
+ switch (extraFontFlag & FontQuality::QualityMask) {
- case SC_EFF_QUALITY_NON_ANTIALIASED:
+ case FontQuality::QualityNonAntialiased:
return D2D1_TEXT_ANTIALIAS_MODE_ALIASED;
- case SC_EFF_QUALITY_ANTIALIASED:
+ case FontQuality::QualityAntialiased:
return D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
- case SC_EFF_QUALITY_LCD_OPTIMIZED:
+ case FontQuality::QualityLcdOptimized:
return D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
default:
@@ -256,11 +258,11 @@ struct FontWin : public Font {
virtual HFONT HFont() const noexcept = 0;
};
-void SetLogFont(LOGFONTW &lf, const char *faceName, int characterSet, XYPOSITION size, int weight, bool italic, int extraFontFlag) {
+void SetLogFont(LOGFONTW &lf, const char *faceName, CharacterSet characterSet, XYPOSITION size, FontWeight weight, bool italic, FontQuality extraFontFlag) {
lf = LOGFONTW();
// The negative is to allow for leading
lf.lfHeight = -(std::abs(std::lround(size)));
- lf.lfWeight = weight;
+ lf.lfWeight = static_cast<LONG>(weight);
lf.lfItalic = italic ? 1 : 0;
lf.lfCharSet = static_cast<BYTE>(characterSet);
lf.lfQuality = Win32MapFontQuality(extraFontFlag);
@@ -296,8 +298,8 @@ struct FontGDI : public FontWin {
#if defined(USE_D2D)
struct FontDirectWrite : public FontWin {
IDWriteTextFormat *pTextFormat = nullptr;
- int extraFontFlag = SC_EFF_QUALITY_DEFAULT;
- int characterSet = 0;
+ FontQuality extraFontFlag = FontQuality::QualityDefault;
+ CharacterSet characterSet = CharacterSet::Ansi;
FLOAT yAscent = 2.0f;
FLOAT yDescent = 1.0f;
FLOAT yInternalLeading = 0.0f;
@@ -372,7 +374,7 @@ struct FontDirectWrite : public FontWin {
std::shared_ptr<Font> Font::Allocate(const FontParameters &fp) {
#if defined(USE_D2D)
- if (fp.technology != SCWIN_TECH_GDI) {
+ if (fp.technology != Technology::Default) {
return std::make_shared<FontDirectWrite>(fp);
}
#endif
@@ -414,7 +416,7 @@ public:
int tlen; // Using int instead of size_t as most Win32 APIs take int.
TextWide(std::string_view text, int codePage) :
VarBuffer<wchar_t, stackBufferLength>(text.length()) {
- if (codePage == SC_CP_UTF8) {
+ if (codePage == CpUtf8) {
tlen = static_cast<int>(UTF16FromUTF8(text, buffer, text.length()));
} else {
// Support Asian string display in 9x English
@@ -492,7 +494,7 @@ public:
void SetMode(SurfaceMode mode_) override;
void Release() noexcept override;
- int Supports(int feature) noexcept override;
+ int SupportsFeature(Supports feature) noexcept override;
bool Initialised() override;
int LogPixelsY() override;
int PixelDivisions() override;
@@ -593,8 +595,8 @@ void SurfaceGDI::Release() noexcept {
Clear();
}
-int SurfaceGDI::Supports(int feature) noexcept {
- for (const int f : SupportsGDI) {
+int SurfaceGDI::SupportsFeature(Supports feature) noexcept {
+ for (const Supports f : SupportsGDI) {
if (f == feature)
return 1;
}
@@ -1033,7 +1035,7 @@ void SurfaceGDI::DrawTextCommon(PRectangle rc, const Font *font_, XYPOSITION yba
const int x = static_cast<int>(rc.left);
const int yBaseInt = static_cast<int>(ybase);
- if (mode.codePage == SC_CP_UTF8) {
+ if (mode.codePage == CpUtf8) {
const TextWide tbuf(text, mode.codePage);
::ExtTextOutW(hdc, x, yBaseInt, fuOptions, &rcw, tbuf.buffer, tbuf.tlen, nullptr);
} else {
@@ -1077,7 +1079,7 @@ void SurfaceGDI::MeasureWidths(const Font *font_, std::string_view text, XYPOSIT
int fit = 0;
int i = 0;
const int len = static_cast<int>(text.length());
- if (mode.codePage == SC_CP_UTF8) {
+ if (mode.codePage == CpUtf8) {
const TextWide tbuf(text, mode.codePage);
TextPositionsI poses(tbuf.tlen);
if (!::GetTextExtentExPointW(hdc, tbuf.buffer, tbuf.tlen, maxWidthMeasure, &fit, poses.buffer, &sz)) {
@@ -1114,7 +1116,7 @@ void SurfaceGDI::MeasureWidths(const Font *font_, std::string_view text, XYPOSIT
XYPOSITION SurfaceGDI::WidthText(const Font *font_, std::string_view text) {
SetFont(font_);
SIZE sz = { 0,0 };
- if (!(mode.codePage == SC_CP_UTF8)) {
+ if (!(mode.codePage == CpUtf8)) {
::GetTextExtentPoint32A(hdc, text.data(), std::min(static_cast<int>(text.length()), maxLenText), &sz);
} else {
const TextWide tbuf(text, mode.codePage);
@@ -1129,7 +1131,7 @@ void SurfaceGDI::DrawTextCommonUTF8(PRectangle rc, const Font *font_, XYPOSITION
const int x = static_cast<int>(rc.left);
const int yBaseInt = static_cast<int>(ybase);
- const TextWide tbuf(text, SC_CP_UTF8);
+ const TextWide tbuf(text, CpUtf8);
::ExtTextOutW(hdc, x, yBaseInt, fuOptions, &rcw, tbuf.buffer, tbuf.tlen, nullptr);
}
@@ -1169,7 +1171,7 @@ void SurfaceGDI::MeasureWidthsUTF8(const Font *font_, std::string_view text, XYP
int fit = 0;
int i = 0;
const int len = static_cast<int>(text.length());
- const TextWide tbuf(text, SC_CP_UTF8);
+ const TextWide tbuf(text, CpUtf8);
TextPositionsI poses(tbuf.tlen);
if (!::GetTextExtentExPointW(hdc, tbuf.buffer, tbuf.tlen, maxWidthMeasure, &fit, poses.buffer, &sz)) {
// Failure
@@ -1194,7 +1196,7 @@ void SurfaceGDI::MeasureWidthsUTF8(const Font *font_, std::string_view text, XYP
XYPOSITION SurfaceGDI::WidthTextUTF8(const Font *font_, std::string_view text) {
SetFont(font_);
SIZE sz = { 0,0 };
- const TextWide tbuf(text, SC_CP_UTF8);
+ const TextWide tbuf(text, CpUtf8);
::GetTextExtentPoint32W(hdc, tbuf.buffer, tbuf.tlen, &sz);
return static_cast<XYPOSITION>(sz.cx);
}
@@ -1269,11 +1271,11 @@ constexpr D2D1_POINT_2F DPointFromPoint(Point point) noexcept {
return { static_cast<FLOAT>(point.x), static_cast<FLOAT>(point.y) };
}
-const int SupportsD2D[] = {
- SC_SUPPORTS_LINE_DRAWS_FINAL,
- SC_SUPPORTS_FRACTIONAL_STROKE_WIDTH,
- SC_SUPPORTS_TRANSLUCENT_STROKE,
- SC_SUPPORTS_PIXEL_MODIFICATION,
+const Supports SupportsD2D[] = {
+ Supports::LineDrawsFinal,
+ Supports::FractionalStrokeWidth,
+ Supports::TranslucentStroke,
+ Supports::PixelModification,
};
constexpr D2D_COLOR_F ColorFromColourAlpha(ColourRGBA colour) noexcept {
@@ -1338,7 +1340,7 @@ public:
void SetMode(SurfaceMode mode_) override;
void Release() noexcept override;
- int Supports(int feature) noexcept override;
+ int SupportsFeature(Supports feature) noexcept override;
bool Initialised() override;
void D2DPenColourAlpha(ColourRGBA fore) noexcept;
@@ -1442,8 +1444,8 @@ void SurfaceD2D::SetScale(WindowID wid) noexcept {
logPixelsY = DpiForWindow(wid);
}
-int SurfaceD2D::Supports(int feature) noexcept {
- for (const int f : SupportsD2D) {
+int SurfaceD2D::SupportsFeature(Supports feature) noexcept {
+ for (const Supports f : SupportsD2D) {
if (f == feature)
return 1;
}
@@ -1503,8 +1505,8 @@ void SurfaceD2D::SetFont(const Font *font_) {
yDescent = pfm->yDescent;
yInternalLeading = pfm->yInternalLeading;
codePageText = mode.codePage;
- if (!(mode.codePage == SC_CP_UTF8) && pfm->characterSet) {
- codePageText = Scintilla::CodePageFromCharSet(pfm->characterSet, mode.codePage);
+ if (!(mode.codePage == CpUtf8) && (pfm->characterSet != CharacterSet::Ansi)) {
+ codePageText = CodePageFromCharSet(pfm->characterSet, mode.codePage);
}
if (pRenderTarget) {
D2D1_TEXT_ANTIALIAS_MODE aaMode;
@@ -2130,7 +2132,7 @@ void ScreenLineLayout::FillTextLayoutFormats(const IScreenLine *screenLine, IDWr
/* Convert to a wide character string and replace tabs with X to stop DirectWrite tab expansion */
std::wstring ScreenLineLayout::ReplaceRepresentation(std::string_view text) {
- const TextWide wideText(text, SC_CP_UTF8);
+ const TextWide wideText(text, CpUtf8);
std::wstring ws(wideText.buffer, wideText.tlen);
std::replace(ws.begin(), ws.end(), L'\t', L'X');
return ws;
@@ -2421,7 +2423,7 @@ void SurfaceD2D::MeasureWidths(const Font *font_, std::string_view text, XYPOSIT
position += clusterMetrics[ci].width;
}
PLATFORM_ASSERT(ti == tbuf.tlen);
- if (mode.codePage == SC_CP_UTF8) {
+ if (mode.codePage == CpUtf8) {
// Map the widths given for UTF-16 characters back onto the UTF-8 input string
size_t i = 0;
for (int ui = 0; ui < tbuf.tlen; ui++) {
@@ -2487,7 +2489,7 @@ void SurfaceD2D::DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION
if (pRenderTarget) {
FillRectangleAligned(rc, back);
D2DPenColourAlpha(fore);
- DrawTextCommon(rc, font_, ybase, text, SC_CP_UTF8, ETO_OPAQUE);
+ DrawTextCommon(rc, font_, ybase, text, CpUtf8, ETO_OPAQUE);
}
}
@@ -2496,7 +2498,7 @@ void SurfaceD2D::DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITIO
if (pRenderTarget) {
FillRectangleAligned(rc, back);
D2DPenColourAlpha(fore);
- DrawTextCommon(rc, font_, ybase, text, SC_CP_UTF8, ETO_OPAQUE | ETO_CLIPPED);
+ DrawTextCommon(rc, font_, ybase, text, CpUtf8, ETO_OPAQUE | ETO_CLIPPED);
}
}
@@ -2507,7 +2509,7 @@ void SurfaceD2D::DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOS
if (ch != ' ') {
if (pRenderTarget) {
D2DPenColourAlpha(fore);
- DrawTextCommon(rc, font_, ybase, text, SC_CP_UTF8, 0);
+ DrawTextCommon(rc, font_, ybase, text, CpUtf8, 0);
}
return;
}
@@ -2520,7 +2522,7 @@ void SurfaceD2D::MeasureWidthsUTF8(const Font *font_, std::string_view text, XYP
// SetFont failed or no access to DirectWrite so give up.
return;
}
- const TextWide tbuf(text, SC_CP_UTF8);
+ const TextWide tbuf(text, CpUtf8);
TextPositions poses(tbuf.tlen);
// Initialize poses for safety.
std::fill(poses.buffer, poses.buffer + tbuf.tlen, 0.0f);
@@ -2570,7 +2572,7 @@ void SurfaceD2D::MeasureWidthsUTF8(const Font *font_, std::string_view text, XYP
XYPOSITION SurfaceD2D::WidthTextUTF8(const Font * font_, std::string_view text) {
FLOAT width = 1.0;
SetFont(font_);
- const TextWide tbuf(text, SC_CP_UTF8);
+ const TextWide tbuf(text, CpUtf8);
if (pIDWriteFactory && pTextFormat) {
// Create a layout
IDWriteTextLayout *pTextLayout = nullptr;
@@ -2651,9 +2653,9 @@ void SurfaceD2D::FlushDrawing() {
#endif
-std::unique_ptr<Surface> Surface::Allocate(int technology) {
+std::unique_ptr<Surface> Surface::Allocate(Technology technology) {
#if defined(USE_D2D)
- if (technology == SCWIN_TECH_GDI)
+ if (technology == Technology::Default)
return std::make_unique<SurfaceGDI>();
else
return std::make_unique<SurfaceD2D>();
@@ -2909,7 +2911,7 @@ ListBox::~ListBox() noexcept {
class ListBoxX : public ListBox {
int lineHeight;
HFONT fontCopy;
- int technology;
+ Technology technology;
RGBAImageSet images;
LineToItem lti;
HWND lb;
@@ -2954,7 +2956,7 @@ class ListBoxX : public ListBox {
static constexpr Point ImageInset {1, 0}; // Padding around image
public:
- ListBoxX() : lineHeight(10), fontCopy{}, technology(0), lb{}, unicodeMode(false),
+ ListBoxX() : lineHeight(10), fontCopy{}, technology(Technology::Default), lb{}, unicodeMode(false),
desiredVisibleRows(9), maxItemCharacters(0), aveCharWidth(8),
parent(nullptr), ctrlID(0), dpi(USER_DEFAULT_SCREEN_DPI),
delegate(nullptr),
@@ -2971,7 +2973,7 @@ public:
}
}
void SetFont(const Font *font) override;
- void Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_, int technology_) override;
+ void Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_, Technology technology_) override;
void SetAverageCharWidth(int width) override;
void SetVisibleRows(int rows) override;
int GetVisibleRows() const override;
@@ -2999,7 +3001,7 @@ std::unique_ptr<ListBox> ListBox::Allocate() {
return std::make_unique<ListBoxX>();
}
-void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_, int technology_) {
+void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHeight_, bool unicodeMode_, Technology technology_) {
parent = &parent_;
ctrlID = ctrlID_;
location = location_;
@@ -3067,7 +3069,7 @@ PRectangle ListBoxX::GetDesiredRect() {
if (widestItem) {
len = static_cast<int>(strlen(widestItem));
if (unicodeMode) {
- const TextWide tbuf(widestItem, SC_CP_UTF8);
+ const TextWide tbuf(widestItem, CpUtf8);
::GetTextExtentPoint32W(hdc, tbuf.buffer, tbuf.tlen, &textSize);
} else {
::GetTextExtentPoint32A(hdc, widestItem, len, &textSize);
@@ -3201,7 +3203,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) {
::InsetRect(&rcText, static_cast<int>(TextInset.x), static_cast<int>(TextInset.y));
if (unicodeMode) {
- const TextWide tbuf(text, SC_CP_UTF8);
+ const TextWide tbuf(text, CpUtf8);
::DrawTextW(pDrawItem->hDC, tbuf.buffer, tbuf.tlen, &rcText, DT_NOPREFIX|DT_END_ELLIPSIS|DT_SINGLELINE|DT_NOCLIP);
} else {
::DrawTextA(pDrawItem->hDC, text, len, &rcText, DT_NOPREFIX|DT_END_ELLIPSIS|DT_SINGLELINE|DT_NOCLIP);
@@ -3211,7 +3213,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) {
const RGBAImage *pimage = images.Get(pixId);
if (pimage) {
std::unique_ptr<Surface> surfaceItem(Surface::Allocate(technology));
- if (technology == SCWIN_TECH_GDI) {
+ if (technology == Technology::Default) {
surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem);
const long left = pDrawItem->rcItem.left + static_cast<int>(ItemInset.x + ImageInset.x);
const PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top,
diff --git a/win32/PlatWin.h b/win32/PlatWin.h
index eb4bfb556..dd067bb2b 100644
--- a/win32/PlatWin.h
+++ b/win32/PlatWin.h
@@ -8,7 +8,7 @@
#ifndef PLATWIN_H
#define PLATWIN_H
-namespace Scintilla {
+namespace Scintilla::Internal {
#ifndef USER_DEFAULT_SCREEN_DPI
#define USER_DEFAULT_SCREEN_DPI 96
diff --git a/win32/Scintilla.vcxproj b/win32/Scintilla.vcxproj
index ab54e7861..746da1b03 100644
--- a/win32/Scintilla.vcxproj
+++ b/win32/Scintilla.vcxproj
@@ -30,12 +30,13 @@
<ProjectGuid>{19CCA8B8-46B9-4609-B7CE-198DA19F07BD}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Scintilla</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v141</PlatformToolset>
+ <PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
diff --git a/win32/ScintillaDLL.cxx b/win32/ScintillaDLL.cxx
index 1ecf1c16e..3e448d848 100644
--- a/win32/ScintillaDLL.cxx
+++ b/win32/ScintillaDLL.cxx
@@ -11,24 +11,26 @@
#define WINVER 0x0500
#include <windows.h>
-#include "Scintilla.h"
+#include "ScintillaTypes.h"
#include "ScintillaWin.h"
+using namespace Scintilla;
+
extern "C"
__declspec(dllexport)
sptr_t __stdcall Scintilla_DirectFunction(
- ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) {
- return Scintilla::DirectFunction(sci, iMessage, wParam, lParam);
+ Internal::ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) {
+ return Internal::DirectFunction(sci, iMessage, wParam, lParam);
}
extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved) {
//Platform::DebugPrintf("Scintilla::DllMain %d %d\n", hInstance, dwReason);
if (dwReason == DLL_PROCESS_ATTACH) {
- if (!Scintilla_RegisterClasses(hInstance))
+ if (!Internal::RegisterClasses(hInstance))
return FALSE;
} else if (dwReason == DLL_PROCESS_DETACH) {
if (lpvReserved == NULL) {
- Scintilla::ResourcesRelease(true);
+ Internal::ResourcesRelease(true);
}
}
return TRUE;
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index c6782721f..a443d518b 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -50,14 +50,16 @@
#include <dwrite.h>
#endif
+#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"
@@ -124,6 +126,8 @@
#define MK_ALT 32
#endif
+namespace {
+
// Two idle messages SC_WIN_IDLE and SC_WORK_IDLE.
// SC_WIN_IDLE is low priority so should occur after the next WM_PAINT
@@ -134,10 +138,10 @@ constexpr UINT SC_WIN_IDLE = 5001;
// and delivering SCN_UPDATEUI
constexpr UINT SC_WORK_IDLE = 5002;
-#define SC_INDICATOR_INPUT INDICATOR_IME
-#define SC_INDICATOR_TARGET INDICATOR_IME+1
-#define SC_INDICATOR_CONVERTED INDICATOR_IME+2
-#define SC_INDICATOR_UNKNOWN INDICATOR_IME_MAX
+constexpr int IndicatorInput = static_cast<int>(Scintilla::IndicatorNumbers::Ime);
+constexpr int IndicatorTarget = IndicatorInput + 1;
+constexpr int IndicatorConverted = IndicatorInput + 2;
+constexpr int IndicatorUnknown = IndicatorInput + 3;
#ifndef SCS_CAP_SETRECONVERTSTRING
#define SCS_CAP_SETRECONVERTSTRING 0x00000004
@@ -148,9 +152,12 @@ constexpr UINT SC_WORK_IDLE = 5002;
typedef UINT_PTR (WINAPI *SetCoalescableTimerSig)(HWND hwnd, UINT_PTR nIDEvent,
UINT uElapse, TIMERPROC lpTimerFunc, ULONG uToleranceDelay);
+}
+
// GCC has trouble with the standard COM ABI so do it the old C way with explicit vtables.
using namespace Scintilla;
+using namespace Scintilla::Internal;
namespace {
@@ -192,13 +199,8 @@ constexpr bool KeyboardIsNumericKeypadFunction(uptr_t wParam, sptr_t lParam) {
}
}
-}
-
-class ScintillaWin; // Forward declaration for COM interface subobjects
-
typedef void VFunction(void);
-
/**
*/
class FormatEnumerator {
@@ -237,8 +239,6 @@ public:
DropTarget() noexcept;
};
-namespace {
-
class IMContext {
HWND hwnd;
public:
@@ -310,6 +310,8 @@ public:
}
+namespace Scintilla::Internal {
+
/**
*/
class ScintillaWin :
@@ -379,7 +381,7 @@ class ScintillaWin :
void DisplayCursor(Window::Cursor c) override;
bool DragThreshold(Point ptStart, Point ptNow) override;
void StartDrag() override;
- static int MouseModifiers(uptr_t wParam) noexcept;
+ static KeyMod MouseModifiers(uptr_t wParam) noexcept;
Sci::Position TargetAsUTF8(char *text) const;
Sci::Position EncodedFromUTF8(const char *utf8, char *encoded) const;
@@ -408,7 +410,7 @@ class ScintillaWin :
std::string EncodedFromUTF8(std::string_view utf8) const override;
std::string EncodeWString(std::wstring_view wsv);
- sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t DefWndProc(Message iMessage, uptr_t wParam, sptr_t lParam) override;
void IdleWork() override;
void QueueIdleWork(WorkItems items, Sci::Position upTo) override;
bool SetIdle(bool on) override;
@@ -431,8 +433,8 @@ class ScintillaWin :
void NotifyFocus(bool focus) override;
void SetCtrlID(int identifier) override;
int GetCtrlID() override;
- void NotifyParent(SCNotification scn) override;
- void NotifyDoubleClick(Point pt, int modifiers) override;
+ void NotifyParent(NotificationData scn) override;
+ void NotifyDoubleClick(Point pt, KeyMod modifiers) override;
std::unique_ptr<CaseFolder> CaseFolderForEncoding() override;
std::string CaseMapString(const std::string &s, CaseMapping caseMapping) override;
void Copy() override;
@@ -466,13 +468,13 @@ class ScintillaWin :
sptr_t IMEMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
sptr_t EditMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
sptr_t IdleMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
- sptr_t SciMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+ sptr_t SciMessage(Message iMessage, uptr_t wParam, sptr_t lParam);
public:
~ScintillaWin() override;
// Public for benefit of Scintilla_DirectFunction
- sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
+ sptr_t WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) override;
/// Implement IUnknown
STDMETHODIMP QueryInterface(REFIID riid, PVOID *ppv);
@@ -494,9 +496,6 @@ public:
static bool Register(HINSTANCE hInstance_) noexcept;
static bool Unregister() noexcept;
- friend class DropSource;
- friend class DataObject;
- friend class DropTarget;
bool DragIsRectangularOK(CLIPFORMAT fmt) const noexcept {
return drag.rectangular && (fmt == cfColumnSelect);
}
@@ -589,10 +588,10 @@ void ScintillaWin::Init() {
HMODULE user32 = ::GetModuleHandleW(L"user32.dll");
SetCoalescableTimerFn = DLLFunction<SetCoalescableTimerSig>(user32, "SetCoalescableTimer");
- vs.indicators[SC_INDICATOR_UNKNOWN] = Indicator(INDIC_HIDDEN, ColourRGBA(0, 0, 0xff));
- vs.indicators[SC_INDICATOR_INPUT] = Indicator(INDIC_DOTS, ColourRGBA(0, 0, 0xff));
- vs.indicators[SC_INDICATOR_CONVERTED] = Indicator(INDIC_COMPOSITIONTHICK, ColourRGBA(0, 0, 0xff));
- vs.indicators[SC_INDICATOR_TARGET] = Indicator(INDIC_STRAIGHTBOX, ColourRGBA(0, 0, 0xff));
+ vs.indicators[IndicatorUnknown] = Indicator(IndicatorStyle::Hidden, ColourRGBA(0, 0, 0xff));
+ vs.indicators[IndicatorInput] = Indicator(IndicatorStyle::Dots, ColourRGBA(0, 0, 0xff));
+ vs.indicators[IndicatorConverted] = Indicator(IndicatorStyle::CompositionThick, ColourRGBA(0, 0, 0xff));
+ vs.indicators[IndicatorTarget] = Indicator(IndicatorStyle::StraightBox, ColourRGBA(0, 0, 0xff));
}
void ScintillaWin::Finalise() {
@@ -634,7 +633,7 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) {
drtp.usage = D2D1_RENDER_TARGET_USAGE_NONE;
drtp.minLevel = D2D1_FEATURE_LEVEL_DEFAULT;
- if (technology == SC_TECHNOLOGY_DIRECTWRITEDC) {
+ if (technology == Technology::DirectWriteDC) {
// Explicit pixel format needed.
drtp.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_IGNORE);
@@ -652,7 +651,7 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) {
D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp {};
dhrtp.hwnd = hw;
dhrtp.pixelSize = size;
- dhrtp.presentOptions = (technology == SC_TECHNOLOGY_DIRECTWRITERETAIN) ?
+ dhrtp.presentOptions = (technology == Technology::DirectWriteRetain) ?
D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS : D2D1_PRESENT_OPTIONS_NONE;
ID2D1HwndRenderTarget *pHwndRenderTarget = nullptr;
@@ -678,7 +677,7 @@ void ScintillaWin::EnsureRenderTarget(HDC hdc) {
DropGraphics();
}
- if ((technology == SC_TECHNOLOGY_DIRECTWRITEDC) && pRenderTarget) {
+ if ((technology == Technology::DirectWriteDC) && pRenderTarget) {
RECT rcWindow;
GetClientRect(MainHWND(), &rcWindow);
const HRESULT hr = static_cast<ID2D1DCRenderTarget*>(pRenderTarget)->BindDC(hdc, &rcWindow);
@@ -702,7 +701,7 @@ HWND ScintillaWin::MainHWND() const noexcept {
}
void ScintillaWin::DisplayCursor(Window::Cursor c) {
- if (cursorMode != SC_CURSORNORMAL) {
+ if (cursorMode != CursorShape::Normal) {
c = static_cast<Window::Cursor>(cursorMode);
}
if (c == Window::Cursor::reverseArrow) {
@@ -742,12 +741,15 @@ void ScintillaWin::StartDrag() {
SetDragPosition(SelectionPosition(Sci::invalidPosition));
}
-int ScintillaWin::MouseModifiers(uptr_t wParam) noexcept {
- return ModifierFlags((wParam & MK_SHIFT) != 0,
+KeyMod ScintillaWin::MouseModifiers(uptr_t wParam) noexcept {
+ return ModifierFlags(
+ (wParam & MK_SHIFT) != 0,
(wParam & MK_CONTROL) != 0,
KeyboardIsKeyDown(VK_MENU));
}
+}
+
namespace {
int InputCodePage() noexcept {
@@ -761,36 +763,36 @@ int InputCodePage() noexcept {
return atoi(sCodePage);
}
-/** Map the key codes to their equivalent SCK_ form. */
-int KeyTranslate(int keyIn) noexcept {
+/** Map the key codes to their equivalent Keys:: form. */
+Keys KeyTranslate(int keyIn) noexcept {
//PLATFORM_ASSERT(!keyIn);
switch (keyIn) {
- case VK_DOWN: return SCK_DOWN;
- case VK_UP: return SCK_UP;
- case VK_LEFT: return SCK_LEFT;
- case VK_RIGHT: return SCK_RIGHT;
- case VK_HOME: return SCK_HOME;
- case VK_END: return SCK_END;
- case VK_PRIOR: return SCK_PRIOR;
- case VK_NEXT: return SCK_NEXT;
- case VK_DELETE: return SCK_DELETE;
- case VK_INSERT: return SCK_INSERT;
- case VK_ESCAPE: return SCK_ESCAPE;
- case VK_BACK: return SCK_BACK;
- case VK_TAB: return SCK_TAB;
- case VK_RETURN: return SCK_RETURN;
- case VK_ADD: return SCK_ADD;
- case VK_SUBTRACT: return SCK_SUBTRACT;
- case VK_DIVIDE: return SCK_DIVIDE;
- case VK_LWIN: return SCK_WIN;
- case VK_RWIN: return SCK_RWIN;
- case VK_APPS: return SCK_MENU;
- case VK_OEM_2: return '/';
- case VK_OEM_3: return '`';
- case VK_OEM_4: return '[';
- case VK_OEM_5: return '\\';
- case VK_OEM_6: return ']';
- default: return keyIn;
+ case VK_DOWN: return Keys::Down;
+ case VK_UP: return Keys::Up;
+ case VK_LEFT: return Keys::Left;
+ case VK_RIGHT: return Keys::Right;
+ case VK_HOME: return Keys::Home;
+ case VK_END: return Keys::End;
+ case VK_PRIOR: return Keys::Prior;
+ case VK_NEXT: return Keys::Next;
+ case VK_DELETE: return Keys::Delete;
+ case VK_INSERT: return Keys::Insert;
+ case VK_ESCAPE: return Keys::Escape;
+ case VK_BACK: return Keys::Back;
+ case VK_TAB: return Keys::Tab;
+ case VK_RETURN: return Keys::Return;
+ case VK_ADD: return Keys::Add;
+ case VK_SUBTRACT: return Keys::Subtract;
+ case VK_DIVIDE: return Keys::Divide;
+ case VK_LWIN: return Keys::Win;
+ case VK_RWIN: return Keys::RWin;
+ case VK_APPS: return Keys::Menu;
+ case VK_OEM_2: return static_cast<Keys>('/');
+ case VK_OEM_3: return static_cast<Keys>('`');
+ case VK_OEM_4: return static_cast<Keys>('[');
+ case VK_OEM_5: return static_cast<Keys>('\\');
+ case VK_OEM_6: return static_cast<Keys>(']');
+ default: return static_cast<Keys>(keyIn);
}
}
@@ -880,9 +882,9 @@ Sci::Position ScintillaWin::TargetAsUTF8(char *text) const {
// Need to convert
const std::string s = RangeText(targetRange.start.Position(), targetRange.end.Position());
const std::wstring characters = StringDecode(s, CodePageOfDocument());
- const int utf8Len = MultiByteLenFromWideChar(CP_UTF8, characters);
+ const int utf8Len = MultiByteLenFromWideChar(CpUtf8, characters);
if (text) {
- MultiByteFromWideChar(CP_UTF8, characters, text, utf8Len);
+ MultiByteFromWideChar(CpUtf8, characters, text, utf8Len);
text[utf8Len] = '\0';
}
return utf8Len;
@@ -902,9 +904,9 @@ Sci::Position ScintillaWin::EncodedFromUTF8(const char *utf8, char *encoded) con
} else {
// Need to convert
const std::string_view utf8Input(utf8, inputLength);
- const int charsLen = WideCharLenFromMultiByte(CP_UTF8, utf8Input);
+ const int charsLen = WideCharLenFromMultiByte(CpUtf8, utf8Input);
std::wstring characters(charsLen, L'\0');
- WideCharFromMultiByte(CP_UTF8, utf8Input, &characters[0], charsLen);
+ WideCharFromMultiByte(CpUtf8, utf8Input, &characters[0], charsLen);
const int encodedLen = MultiByteLenFromWideChar(CodePageOfDocument(), characters);
if (encoded) {
@@ -916,7 +918,7 @@ Sci::Position ScintillaWin::EncodedFromUTF8(const char *utf8, char *encoded) con
}
bool ScintillaWin::PaintDC(HDC hdc) {
- if (technology == SC_TECHNOLOGY_DEFAULT) {
+ if (technology == Technology::Default) {
AutoSurface surfaceWindow(hdc, this);
if (surfaceWindow) {
Paint(surfaceWindow, rcPaint);
@@ -987,7 +989,7 @@ sptr_t ScintillaWin::HandleCompositionWindowed(uptr_t wParam, sptr_t lParam) {
if (lParam & GCS_RESULTSTR) {
IMContext imc(MainHWND());
if (imc.hIMC) {
- AddWString(imc.GetCompositionString(GCS_RESULTSTR), CharacterSource::imeResult);
+ AddWString(imc.GetCompositionString(GCS_RESULTSTR), CharacterSource::ImeResult);
// Set new position after converted
const Point pos = PointMainCaret();
@@ -1020,7 +1022,7 @@ void ScintillaWin::DrawImeIndicator(int indicator, Sci::Position len) {
// Draw an indicator on the character before caret by the character bytes of len
// so it should be called after InsertCharacter().
// It does not affect caret positions.
- if (indicator < 8 || indicator > INDICATOR_MAX) {
+ if (indicator < 8 || indicator > IndicatorMax) {
return;
}
pdoc->DecorationSetCurrentIndicator(indicator);
@@ -1123,21 +1125,21 @@ void ScintillaWin::ToggleHanja() {
namespace {
std::vector<int> MapImeIndicators(std::vector<BYTE> inputStyle) {
- std::vector<int> imeIndicator(inputStyle.size(), SC_INDICATOR_UNKNOWN);
+ std::vector<int> imeIndicator(inputStyle.size(), IndicatorUnknown);
for (size_t i = 0; i < inputStyle.size(); i++) {
switch (static_cast<int>(inputStyle.at(i))) {
case ATTR_INPUT:
- imeIndicator[i] = SC_INDICATOR_INPUT;
+ imeIndicator[i] = IndicatorInput;
break;
case ATTR_TARGET_NOTCONVERTED:
case ATTR_TARGET_CONVERTED:
- imeIndicator[i] = SC_INDICATOR_TARGET;
+ imeIndicator[i] = IndicatorTarget;
break;
case ATTR_CONVERTED:
- imeIndicator[i] = SC_INDICATOR_CONVERTED;
+ imeIndicator[i] = IndicatorConverted;
break;
default:
- imeIndicator[i] = SC_INDICATOR_UNKNOWN;
+ imeIndicator[i] = IndicatorUnknown;
break;
}
}
@@ -1184,7 +1186,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
view.imeCaretBlockOverride = false;
if (lParam & GCS_RESULTSTR) {
- AddWString(imc.GetCompositionString(GCS_RESULTSTR), CharacterSource::imeResult);
+ AddWString(imc.GetCompositionString(GCS_RESULTSTR), CharacterSource::ImeResult);
}
if (lParam & GCS_COMPSTR) {
@@ -1210,7 +1212,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
const size_t ucWidth = UTF16CharLength(wsv[i]);
const std::string docChar = StringEncode(wsv.substr(i, ucWidth), codePage);
- InsertCharacter(docChar, CharacterSource::tentativeInput);
+ InsertCharacter(docChar, CharacterSource::TentativeInput);
DrawImeIndicator(imeIndicator[i], docChar.size());
i += ucWidth;
@@ -1221,7 +1223,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
// After candidate item been added, it's looks like been full selected, it's better to keep caret
// at end of "selection" (end of input) instead of jump to beginning of input ("selection").
const bool onlyTarget = std::all_of(imeIndicator.begin(), imeIndicator.end(), [](int i) noexcept {
- return i == SC_INDICATOR_TARGET;
+ return i == IndicatorTarget;
});
if (!onlyTarget) {
// CS_NOMOVECARET: keep caret at beginning of composition string which already moved in InsertCharacter().
@@ -1237,7 +1239,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
MoveImeCarets(-currentPos + imeCaretPosDoc);
- if (std::find(imeIndicator.begin(), imeIndicator.end(), SC_INDICATOR_TARGET) != imeIndicator.end()) {
+ if (std::find(imeIndicator.begin(), imeIndicator.end(), IndicatorTarget) != imeIndicator.end()) {
// set candidate window left aligned to beginning of target string.
SetCandidateWindowPos();
}
@@ -1255,65 +1257,66 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
namespace {
-// Translate message IDs from WM_* and EM_* to SCI_* so can partly emulate Windows Edit control
-unsigned int SciMessageFromEM(unsigned int iMessage) noexcept {
+// Translate message IDs from WM_* and EM_* to Message::* so can partly emulate Windows Edit control
+Message SciMessageFromEM(unsigned int iMessage) noexcept {
switch (iMessage) {
- case EM_CANPASTE: return SCI_CANPASTE;
- case EM_CANUNDO: return SCI_CANUNDO;
- case EM_EMPTYUNDOBUFFER: return SCI_EMPTYUNDOBUFFER;
- case EM_FINDTEXTEX: return SCI_FINDTEXT;
- case EM_FORMATRANGE: return SCI_FORMATRANGE;
- case EM_GETFIRSTVISIBLELINE: return SCI_GETFIRSTVISIBLELINE;
- case EM_GETLINECOUNT: return SCI_GETLINECOUNT;
- case EM_GETSELTEXT: return SCI_GETSELTEXT;
- case EM_GETTEXTRANGE: return SCI_GETTEXTRANGE;
- case EM_HIDESELECTION: return SCI_HIDESELECTION;
- case EM_LINEINDEX: return SCI_POSITIONFROMLINE;
- case EM_LINESCROLL: return SCI_LINESCROLL;
- case EM_REPLACESEL: return SCI_REPLACESEL;
- case EM_SCROLLCARET: return SCI_SCROLLCARET;
- case EM_SETREADONLY: return SCI_SETREADONLY;
- case WM_CLEAR: return SCI_CLEAR;
- case WM_COPY: return SCI_COPY;
- case WM_CUT: return SCI_CUT;
- case WM_SETTEXT: return SCI_SETTEXT;
- case WM_PASTE: return SCI_PASTE;
- case WM_UNDO: return SCI_UNDO;
- }
- return iMessage;
-}
-
-}
-
-namespace Scintilla {
-
-UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) noexcept {
- if (documentCodePage == SC_CP_UTF8) {
- return SC_CP_UTF8;
+ case EM_CANPASTE: return Message::CanPaste;
+ case EM_CANUNDO: return Message::CanUndo;
+ case EM_EMPTYUNDOBUFFER: return Message::EmptyUndoBuffer;
+ case EM_FINDTEXTEX: return Message::FindText;
+ case EM_FORMATRANGE: return Message::FormatRange;
+ case EM_GETFIRSTVISIBLELINE: return Message::GetFirstVisibleLine;
+ case EM_GETLINECOUNT: return Message::GetLineCount;
+ case EM_GETSELTEXT: return Message::GetSelText;
+ case EM_GETTEXTRANGE: return Message::GetTextRange;
+ case EM_HIDESELECTION: return Message::HideSelection;
+ case EM_LINEINDEX: return Message::PositionFromLine;
+ case EM_LINESCROLL: return Message::LineScroll;
+ case EM_REPLACESEL: return Message::ReplaceSel;
+ case EM_SCROLLCARET: return Message::ScrollCaret;
+ case EM_SETREADONLY: return Message::SetReadOnly;
+ case WM_CLEAR: return Message::Clear;
+ case WM_COPY: return Message::Copy;
+ case WM_CUT: return Message::Cut;
+ case WM_SETTEXT: return Message::SetText;
+ case WM_PASTE: return Message::Paste;
+ case WM_UNDO: return Message::Undo;
+ }
+ return static_cast<Message>(iMessage);
+}
+
+}
+
+namespace Scintilla::Internal {
+
+UINT CodePageFromCharSet(CharacterSet characterSet, UINT documentCodePage) noexcept {
+ if (documentCodePage == CpUtf8) {
+ return CpUtf8;
}
switch (characterSet) {
- case SC_CHARSET_ANSI: return 1252;
- case SC_CHARSET_DEFAULT: return documentCodePage ? documentCodePage : 1252;
- case SC_CHARSET_BALTIC: return 1257;
- case SC_CHARSET_CHINESEBIG5: return 950;
- case SC_CHARSET_EASTEUROPE: return 1250;
- case SC_CHARSET_GB2312: return 936;
- case SC_CHARSET_GREEK: return 1253;
- case SC_CHARSET_HANGUL: return 949;
- case SC_CHARSET_MAC: return 10000;
- case SC_CHARSET_OEM: return 437;
- case SC_CHARSET_RUSSIAN: return 1251;
- case SC_CHARSET_SHIFTJIS: return 932;
- case SC_CHARSET_TURKISH: return 1254;
- case SC_CHARSET_JOHAB: return 1361;
- case SC_CHARSET_HEBREW: return 1255;
- case SC_CHARSET_ARABIC: return 1256;
- case SC_CHARSET_VIETNAMESE: return 1258;
- case SC_CHARSET_THAI: return 874;
- case SC_CHARSET_8859_15: return 28605;
+ case CharacterSet::Ansi: return 1252;
+ case CharacterSet::Default: return documentCodePage ? documentCodePage : 1252;
+ case CharacterSet::Baltic: return 1257;
+ case CharacterSet::ChineseBig5: return 950;
+ case CharacterSet::EastEurope: return 1250;
+ case CharacterSet::GB2312: return 936;
+ case CharacterSet::Greek: return 1253;
+ case CharacterSet::Hangul: return 949;
+ case CharacterSet::Mac: return 10000;
+ case CharacterSet::Oem: return 437;
+ case CharacterSet::Russian: return 1251;
+ case CharacterSet::ShiftJis: return 932;
+ case CharacterSet::Turkish: return 1254;
+ case CharacterSet::Johab: return 1361;
+ case CharacterSet::Hebrew: return 1255;
+ case CharacterSet::Arabic: return 1256;
+ case CharacterSet::Vietnamese: return 1258;
+ case CharacterSet::Thai: return 874;
+ case CharacterSet::Iso8859_15: return 28605;
// Not supported
- case SC_CHARSET_CYRILLIC: return documentCodePage;
- case SC_CHARSET_SYMBOL: return documentCodePage;
+ case CharacterSet::Cyrillic: return documentCodePage;
+ case CharacterSet::Symbol: return documentCodePage;
+ default: break;
}
return documentCodePage;
}
@@ -1321,7 +1324,7 @@ UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) noexcept {
}
UINT ScintillaWin::CodePageOfDocument() const noexcept {
- return CodePageFromCharSet(vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
+ return CodePageFromCharSet(vs.styles[StyleDefault].characterSet, pdoc->dbcsCodePage);
}
std::string ScintillaWin::EncodeWString(std::wstring_view wsv) {
@@ -1526,9 +1529,9 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l
// Zoom! We play with the font sizes in the styles.
// Number of steps/line is ignored, we just care if sizing up or down
if (linesToScroll < 0) {
- KeyCommand(SCI_ZOOMIN);
+ KeyCommand(Message::ZoomIn);
} else {
- KeyCommand(SCI_ZOOMOUT);
+ KeyCommand(Message::ZoomOut);
}
} else {
// Scroll
@@ -1558,7 +1561,8 @@ sptr_t ScintillaWin::KeyMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa
// Don't interpret these as they may be characters entered by number.
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
- const int ret = KeyDownWithModifiers(KeyTranslate(static_cast<int>(wParam)),
+ const int ret = KeyDownWithModifiers(
+ static_cast<Keys>(KeyTranslate(static_cast<int>(wParam))),
ModifierFlags(KeyboardIsKeyDown(VK_SHIFT),
KeyboardIsKeyDown(VK_CONTROL),
altDown),
@@ -1587,7 +1591,7 @@ sptr_t ScintillaWin::KeyMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa
lastHighSurrogateChar = 0;
wclen = 2;
}
- AddWString(std::wstring_view(wcs, wclen), CharacterSource::directInput);
+ AddWString(std::wstring_view(wcs, wclen), CharacterSource::DirectInput);
}
return 0;
@@ -1599,7 +1603,7 @@ sptr_t ScintillaWin::KeyMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa
} else {
wchar_t wcs[3] = { 0 };
const size_t wclen = UTF16FromUTF32Character(static_cast<unsigned int>(wParam), wcs);
- AddWString(std::wstring_view(wcs, wclen), CharacterSource::directInput);
+ AddWString(std::wstring_view(wcs, wclen), CharacterSource::DirectInput);
return FALSE;
}
}
@@ -1659,7 +1663,7 @@ sptr_t ScintillaWin::IMEMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa
}
case WM_IME_STARTCOMPOSITION:
- if (KoreanIME() || imeInteraction == IMEInteraction::internal) {
+ if (KoreanIME() || imeInteraction == IMEInteraction::Inline) {
return 0;
} else {
ImeStartComposition();
@@ -1671,14 +1675,14 @@ sptr_t ScintillaWin::IMEMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_IME_COMPOSITION:
- if (KoreanIME() || imeInteraction == IMEInteraction::internal) {
+ if (KoreanIME() || imeInteraction == IMEInteraction::Inline) {
return HandleCompositionInline(wParam, lParam);
} else {
return HandleCompositionWindowed(wParam, lParam);
}
case WM_IME_SETCONTEXT:
- if (KoreanIME() || imeInteraction == IMEInteraction::internal) {
+ if (KoreanIME() || imeInteraction == IMEInteraction::Inline) {
if (wParam) {
LPARAM NoImeWin = lParam;
NoImeWin = NoImeWin & (~ISC_SHOWUICOMPOSITIONWINDOW);
@@ -1797,34 +1801,34 @@ sptr_t ScintillaWin::IdleMessage(unsigned int iMessage, uptr_t wParam, sptr_t lP
return 0;
}
-sptr_t ScintillaWin::SciMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+sptr_t ScintillaWin::SciMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
switch (iMessage) {
- case SCI_GETDIRECTFUNCTION:
+ case Message::GetDirectFunction:
return reinterpret_cast<sptr_t>(DirectFunction);
- case SCI_GETDIRECTPOINTER:
+ case Message::GetDirectPointer:
return reinterpret_cast<sptr_t>(this);
- case SCI_GRABFOCUS:
+ case Message::GrabFocus:
::SetFocus(MainHWND());
break;
#ifdef INCLUDE_DEPRECATED_FEATURES
- case SCI_SETKEYSUNICODE:
+ case Message::SETKEYSUNICODE:
break;
- case SCI_GETKEYSUNICODE:
+ case Message::GETKEYSUNICODE:
return true;
#endif
- case SCI_SETTECHNOLOGY:
- if ((wParam == SC_TECHNOLOGY_DEFAULT) ||
- (wParam == SC_TECHNOLOGY_DIRECTWRITERETAIN) ||
- (wParam == SC_TECHNOLOGY_DIRECTWRITEDC) ||
- (wParam == SC_TECHNOLOGY_DIRECTWRITE)) {
- const int technologyNew = static_cast<int>(wParam);
+ case Message::SetTechnology:
+ if (Technology technologyNew = static_cast<Technology>(wParam);
+ (technologyNew == Technology::Default) ||
+ (technologyNew == Technology::DirectWriteRetain) ||
+ (technologyNew == Technology::DirectWriteDC) ||
+ (technologyNew == Technology::DirectWrite)) {
if (technology != technologyNew) {
- if (technologyNew > SC_TECHNOLOGY_DEFAULT) {
+ if (technologyNew > Technology::Default) {
#if defined(USE_D2D)
if (!LoadD2D())
// Failed to load Direct2D or DirectWrite so no effect
@@ -1833,7 +1837,7 @@ sptr_t ScintillaWin::SciMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa
return 0;
#endif
} else {
- bidirectional = EditModel::Bidirectional::bidiDisabled;
+ bidirectional = Bidirectional::Disabled;
}
DropRenderTarget();
technology = technologyNew;
@@ -1844,33 +1848,36 @@ sptr_t ScintillaWin::SciMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa
}
break;
- case SCI_SETBIDIRECTIONAL:
- if (technology == SC_TECHNOLOGY_DEFAULT) {
- bidirectional = EditModel::Bidirectional::bidiDisabled;
- } else if (wParam <= SC_BIDIRECTIONAL_R2L) {
- bidirectional = static_cast<EditModel::Bidirectional>(wParam);
+ case Message::SetBidirectional:
+ if (technology == Technology::Default) {
+ bidirectional = Bidirectional::Disabled;
+ } else if (static_cast<Bidirectional>(wParam) <= Bidirectional::R2L) {
+ bidirectional = static_cast<Bidirectional>(wParam);
}
// Invalidate all cached information including layout.
DropGraphics();
InvalidateStyleRedraw();
break;
- case SCI_TARGETASUTF8:
+ case Message::TargetAsUTF8:
return TargetAsUTF8(CharPtrFromSPtr(lParam));
- case SCI_ENCODEDFROMUTF8:
+ case Message::EncodedFromUTF8:
return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam),
CharPtrFromSPtr(lParam));
+
+ default:
+ break;
}
return 0;
}
-sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+sptr_t ScintillaWin::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
try {
//Platform::DebugPrintf("S M:%x WP:%x L:%x\n", iMessage, wParam, lParam);
- iMessage = SciMessageFromEM(iMessage);
- switch (iMessage) {
+ const unsigned int msg = static_cast<unsigned int>(iMessage);
+ switch (msg) {
case WM_CREATE:
ctrlID = ::GetDlgCtrlID(HwndFromWindow(wMain));
@@ -1890,7 +1897,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_PRINTCLIENT: {
HDC hdc = reinterpret_cast<HDC>(wParam);
if (!IsCompatibleDC(hdc)) {
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), msg, wParam, lParam);
}
FullPaintDC(hdc);
}
@@ -1918,10 +1925,10 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case SC_WIN_IDLE:
case SC_WORK_IDLE:
- return IdleMessage(iMessage, wParam, lParam);
+ return IdleMessage(msg, wParam, lParam);
case WM_GETMINMAXINFO:
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), msg, wParam, lParam);
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
@@ -1929,7 +1936,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_MOUSEMOVE:
case WM_MOUSELEAVE:
case WM_MOUSEWHEEL:
- return MouseMessage(iMessage, wParam, lParam);
+ return MouseMessage(msg, wParam, lParam);
case WM_SETCURSOR:
if (LOWORD(lParam) == HTCLIENT) {
@@ -1940,7 +1947,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
return TRUE;
} else {
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), msg, wParam, lParam);
}
case WM_SYSKEYDOWN:
@@ -1948,7 +1955,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_KEYUP:
case WM_CHAR:
case WM_UNICHAR:
- return KeyMessage(iMessage, wParam, lParam);
+ return KeyMessage(msg, wParam, lParam);
case WM_SETTINGCHANGE:
//Platform::DebugPrintf("Setting Changed\n");
@@ -1963,7 +1970,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_KILLFOCUS:
case WM_SETFOCUS:
- return FocusMessage(iMessage, wParam, lParam);
+ return FocusMessage(msg, wParam, lParam);
case WM_SYSCOLORCHANGE:
//Platform::DebugPrintf("Setting Changed\n");
@@ -1986,7 +1993,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case WM_CONTEXTMENU:
- return ShowContextMenu(iMessage, wParam, lParam);
+ return ShowContextMenu(msg, wParam, lParam);
case WM_ERASEBKGND:
return 1; // Avoid any background erasure as whole window painted.
@@ -2008,7 +2015,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_SYSCOMMAND:
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), msg, wParam, lParam);
case WM_GETTEXTLENGTH:
return GetTextLength();
@@ -2025,7 +2032,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_IME_COMPOSITION:
case WM_IME_SETCONTEXT:
case WM_IME_NOTIFY:
- return IMEMessage(iMessage, wParam, lParam);
+ return IMEMessage(msg, wParam, lParam);
case EM_LINEFROMCHAR:
case EM_EXLINEFROMCHAR:
@@ -2033,34 +2040,33 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case EM_EXGETSEL:
case EM_SETSEL:
case EM_EXSETSEL:
- return EditMessage(iMessage, wParam, lParam);
+ return EditMessage(msg, wParam, lParam);
+ }
- case SCI_GETDIRECTFUNCTION:
- case SCI_GETDIRECTPOINTER:
- case SCI_GRABFOCUS:
-#ifdef INCLUDE_DEPRECATED_FEATURES
- case SCI_SETKEYSUNICODE:
- case SCI_GETKEYSUNICODE:
-#endif
- case SCI_SETTECHNOLOGY:
- case SCI_SETBIDIRECTIONAL:
- case SCI_TARGETASUTF8:
- case SCI_ENCODEDFROMUTF8:
+ iMessage = SciMessageFromEM(msg);
+ switch (iMessage) {
+ case Message::GetDirectFunction:
+ case Message::GetDirectPointer:
+ case Message::GrabFocus:
+ case Message::SetTechnology:
+ case Message::SetBidirectional:
+ case Message::TargetAsUTF8:
+ case Message::EncodedFromUTF8:
return SciMessage(iMessage, wParam, lParam);
default:
return ScintillaBase::WndProc(iMessage, wParam, lParam);
}
} catch (std::bad_alloc &) {
- errorStatus = SC_STATUS_BADALLOC;
+ errorStatus = Status::BadAlloc;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return 0;
}
bool ScintillaWin::ValidCodePage(int codePage) const {
- return codePage == 0 || codePage == SC_CP_UTF8 ||
+ return codePage == 0 || codePage == CpUtf8 ||
codePage == 932 || codePage == 936 || codePage == 949 ||
codePage == 950 || codePage == 1361;
}
@@ -2071,7 +2077,7 @@ std::string ScintillaWin::UTF8FromEncoded(std::string_view encoded) const {
} else {
// Pivot through wide string
std::wstring ws = StringDecode(encoded, CodePageOfDocument());
- return StringEncode(ws, SC_CP_UTF8);
+ return StringEncode(ws, CpUtf8);
}
}
@@ -2080,13 +2086,13 @@ std::string ScintillaWin::EncodedFromUTF8(std::string_view utf8) const {
return std::string(utf8);
} else {
// Pivot through wide string
- std::wstring ws = StringDecode(utf8, SC_CP_UTF8);
+ std::wstring ws = StringDecode(utf8, CpUtf8);
return StringEncode(ws, CodePageOfDocument());
}
}
-sptr_t ScintillaWin::DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
- return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
+sptr_t ScintillaWin::DefWndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
+ return ::DefWindowProc(MainHWND(), static_cast<unsigned int>(iMessage), wParam, lParam);
}
bool ScintillaWin::FineTickerRunning(TickReason reason) {
@@ -2174,12 +2180,12 @@ void ScintillaWin::SetTrackMouseLeaveEvent(bool on) noexcept {
}
void ScintillaWin::UpdateBaseElements() {
- struct ElementToIndex { int element; int nIndex; };
+ struct ElementToIndex { Element element; int nIndex; };
ElementToIndex eti[] = {
- { SC_ELEMENT_LIST, COLOR_WINDOWTEXT },
- { SC_ELEMENT_LIST_BACK, COLOR_WINDOW },
- { SC_ELEMENT_LIST_SELECTED, COLOR_HIGHLIGHTTEXT },
- { SC_ELEMENT_LIST_SELECTED_BACK, COLOR_HIGHLIGHT },
+ { Element::List, COLOR_WINDOWTEXT },
+ { Element::ListBack, COLOR_WINDOW },
+ { Element::ListSelected, COLOR_HIGHLIGHTTEXT },
+ { Element::ListSelectedBack, COLOR_HIGHLIGHT },
};
bool changed = false;
for (const ElementToIndex &ei : eti) {
@@ -2310,14 +2316,14 @@ bool ScintillaWin::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) {
void ScintillaWin::NotifyChange() {
::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
- MAKEWPARAM(GetCtrlID(), SCEN_CHANGE),
+ MAKEWPARAM(GetCtrlID(), FocusChange::Change),
reinterpret_cast<LPARAM>(MainHWND()));
}
void ScintillaWin::NotifyFocus(bool focus) {
if (commandEvents) {
::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
- MAKEWPARAM(GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
+ MAKEWPARAM(GetCtrlID(), focus ? FocusChange::Setfocus : FocusChange::Killfocus),
reinterpret_cast<LPARAM>(MainHWND()));
}
Editor::NotifyFocus(focus);
@@ -2331,20 +2337,20 @@ int ScintillaWin::GetCtrlID() {
return ::GetDlgCtrlID(HwndFromWindow(wMain));
}
-void ScintillaWin::NotifyParent(SCNotification scn) {
+void ScintillaWin::NotifyParent(NotificationData scn) {
scn.nmhdr.hwndFrom = MainHWND();
scn.nmhdr.idFrom = GetCtrlID();
::SendMessage(::GetParent(MainHWND()), WM_NOTIFY,
GetCtrlID(), reinterpret_cast<LPARAM>(&scn));
}
-void ScintillaWin::NotifyDoubleClick(Point pt, int modifiers) {
+void ScintillaWin::NotifyDoubleClick(Point pt, KeyMod modifiers) {
//Platform::DebugPrintf("ScintillaWin Double click 0\n");
ScintillaBase::NotifyDoubleClick(pt, modifiers);
// Send myself a WM_LBUTTONDBLCLK, so the container can handle it too.
::SendMessage(MainHWND(),
WM_LBUTTONDBLCLK,
- (modifiers & SCI_SHIFT) ? MK_SHIFT : 0,
+ FlagSet(modifiers, KeyMod::Shift) ? MK_SHIFT : 0,
MAKELPARAM(pt.x, pt.y));
}
@@ -2409,7 +2415,7 @@ public:
std::unique_ptr<CaseFolder> ScintillaWin::CaseFolderForEncoding() {
const UINT cpDest = CodePageOfDocument();
- if (cpDest == SC_CP_UTF8) {
+ if (cpDest == CpUtf8) {
return std::make_unique<CaseFolderUnicode>();
} else {
if (pdoc->dbcsCodePage == 0) {
@@ -2452,7 +2458,7 @@ std::string ScintillaWin::CaseMapString(const std::string &s, CaseMapping caseMa
return s;
const UINT cpDoc = CodePageOfDocument();
- if (cpDoc == SC_CP_UTF8) {
+ if (cpDoc == CpUtf8) {
return CaseConvertString(s, (caseMapping == CaseMapping::upper) ? CaseConversion::upper : CaseConversion::lower);
}
@@ -2570,7 +2576,7 @@ void ScintillaWin::Paste() {
UndoGroup ug(pdoc);
const bool isLine = SelectionEmpty() &&
(::IsClipboardFormatAvailable(cfLineSelect) || ::IsClipboardFormatAvailable(cfVSLineTag));
- ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH);
+ ClearSelection(multiPasteMode == MultiPaste::Each);
bool isRectangular = (::IsClipboardFormatAvailable(cfColumnSelect) != 0);
if (!isRectangular) {
@@ -2797,10 +2803,10 @@ STDMETHODIMP DataObject_EnumFormatEtc(DataObject *pd, DWORD dwDirection, IEnumFO
return FormatEnumerator_QueryInterface(pfe, IID_IEnumFORMATETC,
reinterpret_cast<void **>(ppEnum));
} catch (std::bad_alloc &) {
- pd->sci->errorStatus = SC_STATUS_BADALLOC;
+ pd->sci->errorStatus = Status::BadAlloc;
return E_OUTOFMEMORY;
} catch (...) {
- pd->sci->errorStatus = SC_STATUS_FAILURE;
+ pd->sci->errorStatus = Status::Failure;
return E_FAIL;
}
}
@@ -2858,7 +2864,7 @@ STDMETHODIMP DropTarget_DragEnter(DropTarget *dt, LPDATAOBJECT pIDataSource, DWO
try {
return dt->sci->DragEnter(pIDataSource, grfKeyState, pt, pdwEffect);
} catch (...) {
- dt->sci->errorStatus = SC_STATUS_FAILURE;
+ dt->sci->errorStatus = Status::Failure;
}
return E_FAIL;
}
@@ -2866,7 +2872,7 @@ STDMETHODIMP DropTarget_DragOver(DropTarget *dt, DWORD grfKeyState, POINTL pt, P
try {
return dt->sci->DragOver(grfKeyState, pt, pdwEffect);
} catch (...) {
- dt->sci->errorStatus = SC_STATUS_FAILURE;
+ dt->sci->errorStatus = Status::Failure;
}
return E_FAIL;
}
@@ -2874,7 +2880,7 @@ STDMETHODIMP DropTarget_DragLeave(DropTarget *dt) {
try {
return dt->sci->DragLeave();
} catch (...) {
- dt->sci->errorStatus = SC_STATUS_FAILURE;
+ dt->sci->errorStatus = Status::Failure;
}
return E_FAIL;
}
@@ -2883,7 +2889,7 @@ STDMETHODIMP DropTarget_Drop(DropTarget *dt, LPDATAOBJECT pIDataSource, DWORD gr
try {
return dt->sci->Drop(pIDataSource, grfKeyState, pt, pdwEffect);
} catch (...) {
- dt->sci->errorStatus = SC_STATUS_FAILURE;
+ dt->sci->errorStatus = Status::Failure;
}
return E_FAIL;
}
@@ -2924,12 +2930,12 @@ void ScintillaWin::ImeStartComposition() {
// The logfont for the IME is recreated here.
const int styleHere = pdoc->StyleIndexAt(sel.MainCaret());
LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L""};
- int sizeZoomed = vs.styles[styleHere].size + vs.zoomLevel * SC_FONT_SIZE_MULTIPLIER;
- if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1
- sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER;
+ int sizeZoomed = vs.styles[styleHere].size + vs.zoomLevel * FontSizeMultiplier;
+ if (sizeZoomed <= 2 * FontSizeMultiplier) // Hangs if sizeZoomed <= 1
+ sizeZoomed = 2 * FontSizeMultiplier;
// The negative is to allow for leading
- lf.lfHeight = -::MulDiv(sizeZoomed, dpi, 72*SC_FONT_SIZE_MULTIPLIER);
- lf.lfWeight = vs.styles[styleHere].weight;
+ lf.lfHeight = -::MulDiv(sizeZoomed, dpi, 72*FontSizeMultiplier);
+ lf.lfWeight = static_cast<LONG>(vs.styles[styleHere].weight);
lf.lfItalic = vs.styles[styleHere].italic ? 1 : 0;
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfFaceName[0] = L'\0';
@@ -3171,7 +3177,7 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
* This paint will not be abandoned.
*/
void ScintillaWin::FullPaint() {
- if ((technology == SC_TECHNOLOGY_DEFAULT) || (technology == SC_TECHNOLOGY_DIRECTWRITEDC)) {
+ if ((technology == Technology::Default) || (technology == Technology::DirectWriteDC)) {
HDC hdc = ::GetDC(MainHWND());
FullPaintDC(hdc);
::ReleaseDC(MainHWND(), hdc);
@@ -3283,7 +3289,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe
return S_OK;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return E_FAIL;
}
@@ -3293,7 +3299,7 @@ STDMETHODIMP ScintillaWin::DragLeave() {
SetDragPosition(SelectionPosition(Sci::invalidPosition));
return S_OK;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return E_FAIL;
}
@@ -3341,7 +3347,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
return S_OK;
} catch (...) {
- errorStatus = SC_STATUS_FAILURE;
+ errorStatus = Status::Failure;
}
return E_FAIL;
}
@@ -3439,7 +3445,7 @@ BOOL ScintillaWin::CreateSystemCaret() {
const BOOL retval = ::CreateCaret(
MainHWND(), sysCaretBitmap,
sysCaretWidth, sysCaretHeight);
- if (technology == SC_TECHNOLOGY_DEFAULT) {
+ if (technology == Technology::Default) {
// System caret interferes with Direct2D drawing so only show it for GDI.
::ShowCaret(MainHWND());
}
@@ -3485,14 +3491,14 @@ LRESULT PASCAL ScintillaWin::CTWndProc(
RECT rc;
GetClientRect(hWnd, &rc);
// Create a Direct2D render target.
- if (sciThis->technology == SC_TECHNOLOGY_DEFAULT) {
+ if (sciThis->technology == Technology::Default) {
surfaceWindow->Init(ps.hdc, hWnd);
} else {
#if defined(USE_D2D)
D2D1_HWND_RENDER_TARGET_PROPERTIES dhrtp;
dhrtp.hwnd = hWnd;
dhrtp.pixelSize = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top);
- dhrtp.presentOptions = (sciThis->technology == SC_TECHNOLOGY_DIRECTWRITERETAIN) ?
+ dhrtp.presentOptions = (sciThis->technology == Technology::DirectWriteRetain) ?
D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS : D2D1_PRESENT_OPTIONS_NONE;
D2D1_RENDER_TARGET_PROPERTIES drtp;
@@ -3550,7 +3556,7 @@ LRESULT PASCAL ScintillaWin::CTWndProc(
}
}
} catch (...) {
- sciThis->errorStatus = SC_STATUS_FAILURE;
+ sciThis->errorStatus = Status::Failure;
}
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
}
@@ -3558,14 +3564,14 @@ LRESULT PASCAL ScintillaWin::CTWndProc(
sptr_t ScintillaWin::DirectFunction(
sptr_t ptr, UINT iMessage, uptr_t wParam, sptr_t lParam) {
PLATFORM_ASSERT(::GetCurrentThreadId() == ::GetWindowThreadProcessId(reinterpret_cast<ScintillaWin *>(ptr)->MainHWND(), nullptr));
- return reinterpret_cast<ScintillaWin *>(ptr)->WndProc(iMessage, wParam, lParam);
+ return reinterpret_cast<ScintillaWin *>(ptr)->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
-namespace Scintilla {
+namespace Scintilla::Internal {
sptr_t DirectFunction(
ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) {
- return sci->WndProc(iMessage, wParam, lParam);
+ return sci->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
}
@@ -3585,7 +3591,7 @@ LRESULT PASCAL ScintillaWin::SWndProc(
// Create C++ object associated with window
sci = new ScintillaWin(hWnd);
SetWindowPointer(hWnd, sci);
- return sci->WndProc(iMessage, wParam, lParam);
+ return sci->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
} catch (...) {
}
@@ -3600,19 +3606,19 @@ LRESULT PASCAL ScintillaWin::SWndProc(
SetWindowPointer(hWnd, nullptr);
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
} else {
- return sci->WndProc(iMessage, wParam, lParam);
+ return sci->WndProc(static_cast<Message>(iMessage), wParam, lParam);
}
}
}
// This function is externally visible so it can be called from container when building statically.
// Must be called once only.
-int Scintilla_RegisterClasses(void *hInstance) {
+extern "C" int Scintilla_RegisterClasses(void *hInstance) {
const bool result = ScintillaWin::Register(static_cast<HINSTANCE>(hInstance));
return result;
}
-namespace Scintilla {
+namespace Scintilla::Internal {
int ResourcesRelease(bool fromDllMain) noexcept {
const bool result = ScintillaWin::Unregister();
@@ -3620,9 +3626,14 @@ int ResourcesRelease(bool fromDllMain) noexcept {
return result;
}
+int RegisterClasses(void *hInstance) noexcept {
+ const bool result = ScintillaWin::Register(static_cast<HINSTANCE>(hInstance));
+ return result;
+}
+
}
// This function is externally visible so it can be called from container when building statically.
-int Scintilla_ReleaseResources() {
- return Scintilla::ResourcesRelease(false);
+extern "C" int Scintilla_ReleaseResources() {
+ return Scintilla::Internal::ResourcesRelease(false);
}
diff --git a/win32/ScintillaWin.h b/win32/ScintillaWin.h
index cce72587d..c46e263de 100644
--- a/win32/ScintillaWin.h
+++ b/win32/ScintillaWin.h
@@ -8,12 +8,13 @@
#ifndef SCINTILLAWIN_H
#define SCINTILLAWIN_H
-class ScintillaWin;
+namespace Scintilla::Internal {
-namespace Scintilla {
+class ScintillaWin;
int ResourcesRelease(bool fromDllMain) noexcept;
-sptr_t DirectFunction(ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam);
+int RegisterClasses(void *hInstance) noexcept;
+Scintilla::sptr_t DirectFunction(ScintillaWin *sci, UINT iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);
}