From 92290868cf9753d2df0d494cb44e2ff62a570b58 Mon Sep 17 00:00:00 2001
From: Neil
Date: Mon, 24 May 2021 19:31:06 +1000
Subject: 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.
---
cocoa/PlatCocoa.h | 22 +-
cocoa/PlatCocoa.mm | 91 +-
cocoa/QuartzTextStyle.h | 8 +-
cocoa/QuartzTextStyleAttribute.h | 4 +-
cocoa/ScintillaCocoa.h | 10 +-
cocoa/ScintillaCocoa.mm | 431 ++--
cocoa/ScintillaView.mm | 127 +-
doc/ScintillaDoc.html | 71 +-
doc/ScintillaHistory.html | 4 +
gtk/PlatGTK.cxx | 90 +-
gtk/ScintillaGTK.cxx | 173 +-
gtk/ScintillaGTK.h | 12 +-
gtk/ScintillaGTKAccessible.cxx | 175 +-
gtk/ScintillaGTKAccessible.h | 18 +-
gtk/deps.mak | 82 +-
include/ILoader.h | 4 +
include/Scintilla.iface | 6 +
include/ScintillaMessages.h | 778 +++++++
include/ScintillaStructures.h | 103 +
include/ScintillaTypes.h | 786 +++++++
qt/ScintillaEdit/ScintillaDocument.cpp | 20 +-
qt/ScintillaEdit/ScintillaDocument.h | 2 +-
qt/ScintillaEditBase/PlatQt.cpp | 77 +-
qt/ScintillaEditBase/PlatQt.h | 8 +-
qt/ScintillaEditBase/ScintillaEditBase.cpp | 29 +-
qt/ScintillaEditBase/ScintillaEditBase.h | 9 +-
qt/ScintillaEditBase/ScintillaQt.cpp | 34 +-
qt/ScintillaEditBase/ScintillaQt.h | 17 +-
scripts/Face.py | 17 +
scripts/HeaderOrder.txt | 13 +-
scripts/ScintillaAPIFacer.py | 107 +
src/AutoComplete.cxx | 19 +-
src/AutoComplete.h | 14 +-
src/CallTip.cxx | 18 +-
src/CallTip.h | 6 +-
src/CaseConvert.cxx | 4 +-
src/CaseConvert.h | 2 +-
src/CaseFolder.cxx | 2 +-
src/CaseFolder.h | 2 +-
src/CellBuffer.cxx | 109 +-
src/CellBuffer.h | 18 +-
src/CharClassify.cxx | 2 +-
src/CharClassify.h | 2 +-
src/CharacterCategoryMap.cxx | 2 +-
src/CharacterCategoryMap.h | 2 +-
src/CharacterType.cxx | 4 +-
src/CharacterType.h | 2 +-
src/ContractionState.cxx | 4 +-
src/ContractionState.h | 2 +-
src/DBCS.cxx | 4 +-
src/DBCS.h | 2 +-
src/Debugging.h | 4 +-
src/Decoration.cxx | 11 +-
src/Decoration.h | 2 +-
src/Document.cxx | 309 +--
src/Document.h | 79 +-
src/EditModel.cxx | 30 +-
src/EditModel.h | 11 +-
src/EditView.cxx | 341 +--
src/EditView.h | 11 +-
src/Editor.cxx | 3110 ++++++++++++++--------------
src/Editor.h | 177 +-
src/ElapsedPeriod.h | 2 +-
src/FontQuality.h | 14 +-
src/Geometry.cxx | 2 +-
src/Geometry.h | 8 +-
src/Indicator.cxx | 66 +-
src/Indicator.h | 22 +-
src/KeyMap.cxx | 200 +-
src/KeyMap.h | 38 +-
src/LineMarker.cxx | 96 +-
src/LineMarker.h | 14 +-
src/MarginView.cxx | 142 +-
src/MarginView.h | 2 +-
src/Partitioning.h | 2 +-
src/PerLine.cxx | 17 +-
src/PerLine.h | 2 +-
src/Platform.h | 24 +-
src/PositionCache.cxx | 36 +-
src/PositionCache.h | 14 +-
src/RESearch.cxx | 2 +-
src/RESearch.h | 2 +-
src/RunStyles.cxx | 11 +-
src/RunStyles.h | 2 +-
src/ScintillaBase.cxx | 341 +--
src/ScintillaBase.h | 20 +-
src/Selection.cxx | 4 +-
src/Selection.h | 2 +-
src/SparseVector.h | 2 +-
src/SplitVector.h | 2 +-
src/Style.cxx | 20 +-
src/Style.h | 20 +-
src/UniConversion.cxx | 4 +-
src/UniConversion.h | 2 +-
src/UniqueString.cxx | 2 +-
src/UniqueString.h | 2 +-
src/ViewStyle.cxx | 269 ++-
src/ViewStyle.h | 102 +-
src/XPM.cxx | 3 +
src/XPM.h | 2 +-
test/unit/UnitTester.cxx | 2 +-
test/unit/testCellBuffer.cxx | 274 +--
test/unit/testCharClassify.cxx | 2 +-
test/unit/testContractionState.cxx | 2 +-
test/unit/testDecoration.cxx | 2 +-
test/unit/testPartitioning.cxx | 2 +-
test/unit/testPerLine.cxx | 31 +-
test/unit/testRunStyles.cxx | 4 +-
test/unit/testSparseVector.cxx | 2 +-
test/unit/testSplitVector.cxx | 2 +-
test/unit/testUniConversion.cxx | 2 +-
test/unit/unitTest.cxx | 2 +-
win32/HanjaDic.cxx | 2 +-
win32/HanjaDic.h | 2 +-
win32/PlatWin.cxx | 118 +-
win32/PlatWin.h | 2 +-
win32/Scintilla.vcxproj | 3 +-
win32/ScintillaDLL.cxx | 12 +-
win32/ScintillaWin.cxx | 483 ++---
win32/ScintillaWin.h | 7 +-
120 files changed, 6042 insertions(+), 4062 deletions(-)
create mode 100644 include/ScintillaMessages.h
create mode 100644 include/ScintillaStructures.h
create mode 100644 include/ScintillaTypes.h
create mode 100644 scripts/ScintillaAPIFacer.py
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
+#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 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
+#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 &positions) {
positions.begin(), std::plus());
}
-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 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 &stops, GradientOptions options) {
+void Scintilla::Internal::SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector &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::Allocate(int) {
+std::unique_ptr Surface::Allocate(Technology) {
return std::make_unique();
}
@@ -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 surfaceBase(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr surfaceBase(Surface::Allocate(Technology::Default));
std::unique_ptr surfaceXPM = surfaceBase->AllocatePixMap(width, height);
SurfaceImpl *surfaceIXPM = static_cast(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(::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 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
#import
+#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(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(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(macMapDefault[i].key); i++)
kmap.AssignCmdKey(macMapDefault[i].key, macMapDefault[i].modifiers, macMapDefault[i].msg);
}
@@ -590,7 +603,7 @@ std::unique_ptr ScintillaCocoa::CaseFolderForEncoding() {
return std::make_unique();
} else {
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
- vs.styles[STYLE_DEFAULT].characterSet);
+ vs.styles[StyleDefault].characterSet);
if (pdoc->dbcsCodePage == 0) {
std::unique_ptr pcf = std::make_unique();
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(contentRect.origin.x), static_cast(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(result.x - ptOrigin.x), static_cast(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(ptr)->WndProc(iMessage, wParam, lParam);
+ return reinterpret_cast(ptr)->WndProc(static_cast(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(DirectFunction);
- case SCI_GETDIRECTPOINTER:
+ case Message::GetDirectPointer:
return reinterpret_cast(this);
- case SCI_SETBIDIRECTIONAL:
- bidirectional = static_cast(wParam);
+ case Message::SetBidirectional:
+ bidirectional = static_cast(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(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 surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr 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(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(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(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 sw(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr 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 sw(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr 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(GetCtrlID()), SCEN_CHANGE),
+ notifyProc(notifyObj, WM_COMMAND, Platform::LongFromTwoShorts(static_cast(GetCtrlID()), static_cast(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(GetCtrlID()),
- (focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS)),
+ static_cast((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(&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(unicodeChar);
case '-':
if (modifierFlags & NSEventModifierFlagNumericPad)
- return SCK_SUBTRACT;
+ return Keys::Subtract;
else
- return unicodeChar;
+ return static_cast(unicodeChar);
case '/':
if (modifierFlags & NSEventModifierFlagNumericPad)
- return SCK_DIVIDE;
+ return Keys::Divide;
else
- return unicodeChar;
+ return static_cast(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(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(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 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(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(WndProc(Message::GetStyleAt, charRange.location, 0));
const long style = static_cast(styleByte);
- std::vector bufferFontName(WndProc(SCI_STYLEGETFONT, style, 0) + 1);
- WndProc(SCI_STYLEGETFONT, style, (sptr_t)&bufferFontName[0]);
+ std::vector 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
#include
+#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; iWndProc(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(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(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(Notification::Zoom) &&
+ scn->nmhdr.code != static_cast(Notification::UpdateUI))
return;
}
- switch (scn->nmhdr.code) {
- case SCN_MARGINCLICK: {
+ switch (static_cast(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((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((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), wParam, lParam);
}
- (sptr_t) message: (unsigned int) message wParam: (uptr_t) wParam {
- return mBackend->WndProc(message, wParam, 0);
+ return mBackend->WndProc(static_cast(message), wParam, 0);
}
- (sptr_t) message: (unsigned int) message {
- return mBackend->WndProc(message, 0, 0);
+ return mBackend->WndProc(static_cast(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(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(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(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(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(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(property), 0, (sptr_t) ref);
}
//--------------------------------------------------------------------------------------------------
@@ -1808,7 +1817,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
long blue = static_cast(value.blueComponent * 255);
long color = (blue << 16) + (green << 8) + red;
- mBackend->WndProc(property, parameter, color);
+ mBackend->WndProc(static_cast(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(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(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(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(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(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(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 @@
Scintilla Documentation
- Last edited 13 May 2021 NH
+ Last edited 25 May 2021 NH
Scintilla 5 has moved the lexers from Scintilla into a new
Lexilla project.
@@ -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.
+ 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.
+
+
In the descriptions that follow, the messages are described as function calls with zero, one
or two arguments. These two arguments are the standard wParam and
lParam familiar to Windows programmers. These parameters are integers that
@@ -274,9 +280,9 @@
alpha |
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 (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
performed opaquely on the base layer. This is now discouraged and code should use the …LAYER…
methods to choose the layer. |
@@ -1649,9 +1655,9 @@ struct Sci_TextToFind {
working in terms of UTF-16 code units.
SCI_GETLINECHARACTERINDEX → int
- Returns which if any indexes are active. It may be SC_LINECHARACTERINDEX_NONE(0) or one or more
- of SC_LINECHARACTERINDEX_UTF32(1) if whole characters are indexed or
- SC_LINECHARACTERINDEX_UTF16(2) if UTF-16 code units are indexed.
+ Returns which if any indexes are active. It may be SC_LINECHARACTERINDEX_NONE (0) or one or more
+ of SC_LINECHARACTERINDEX_UTF32 (1) if whole characters are indexed or
+ SC_LINECHARACTERINDEX_UTF16 (2) if UTF-16 code units are indexed.
Character indexes are currently only supported for UTF-8 documents.
SCI_ALLOCATELINECHARACTERINDEX(int lineCharacterIndex)
@@ -1665,7 +1671,7 @@ struct Sci_TextToFind {
SCI_LINEFROMINDEXPOSITION(position pos, int lineCharacterIndex) → line
SCI_INDEXPOSITIONFROMLINE(line line, int lineCharacterIndex) → position
The document line of a particular character or code unit may be found by calling SCI_LINEFROMINDEXPOSITION with one of
- SC_LINECHARACTERINDEX_UTF32(1) or SC_LINECHARACTERINDEX_UTF16(2).
+ SC_LINECHARACTERINDEX_UTF32 (1) or SC_LINECHARACTERINDEX_UTF16 (2).
The inverse action, finds the starting position of a document line either in characters or code units from the document start by calling
SCI_INDEXPOSITIONFROMLINE with the same lineCharacterIndex argument.
@@ -3722,7 +3728,7 @@ struct Sci_TextToFind {
SCI_SETCARETSTYLE(int caretStyle)
SCI_GETCARETSTYLE → int
The style of the caret can be set with SCI_SETCARETSTYLE.
- There are separate styles for insert mode (lower 4-bits, CARETSTYLE_INS_MASK) and
+ There are separate styles for insert mode (lower 4-bits, CARETSTYLE_INS_MASK) and
overtype mode (bit 4).
@@ -4457,7 +4463,7 @@ struct Sci_TextToFind {
SC_EFF_QUALITY_ANTIALIASED,
SC_EFF_QUALITY_LCD_OPTIMIZED.
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.
+ by SC_EFF_QUALITY_MASK (0xF) will be used for quality.
SCI_SETCODEPAGE(int codePage)
SCI_GETCODEPAGE → int
@@ -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 SC_BIDIRECTIONAL_L2R mode.
Some features, such as virtual space may not work with
- bidirectional text or may work only in some circumstances.
+ bidirectional text or may work only in some circumstances.
+ SC_BIDIRECTIONAL_R2L may be implemented in the future.
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
SCI_SETBIDIRECTIONAL(SC_BIDIRECTIONAL_L2R) (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 INDIC_HIDDEN.
The SCI_INDIC* messages allow you to get and set the visual appearance of the
- indicators. They all use an indicator argument in the range 0 to INDICATOR_MAX(35)
+ indicators. They all use an indicator argument in the range 0 to INDICATOR_MAX(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=INDICATOR_CONTAINER .. 31=INDICATOR_IME-1)
@@ -5525,7 +5532,8 @@ struct Sci_TextToFind {
These messages set and get the flags associated with an indicator.
There is currently one flag defined, SC_INDICFLAG_VALUEFORE: 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 SC_INDICFLAG_NONE is the default.
+ This allows many colours to be displayed for a single indicator. The value is an RGB integer colour that has been ored with SC_INDICVALUEBIT(0x1000000)
when calling SCI_SETINDICATORVALUE.
To find the colour from the value, and the value with SC_INDICVALUEMASK(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.
- SC_FOLDLEVELHEADERFLAG indicates that
- the line is a header (fold point).
+ SC_FOLDLEVELHEADERFLAG indicates that the line is a header (fold point).
+ SC_FOLDLEVELNONE is a default level that may occur before folding.
+
Use SCI_GETFOLDLEVEL(line) & SC_FOLDLEVELNUMBERMASK to get the fold level
of a line. Likewise, use SCI_GETFOLDLEVEL(line) & SC_FOLDLEVEL*FLAG to get the
@@ -6971,6 +6980,12 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
+
+ | SC_FOLDFLAG_NONE |
+ 0 |
+ Default value. |
+
+
|
1 |
@@ -6980,44 +6995,38 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
| SC_FOLDFLAG_LINEBEFORE_EXPANDED |
2 |
-
Draw above if expanded |
| SC_FOLDFLAG_LINEBEFORE_CONTRACTED |
4 |
-
Draw above if not expanded |
| SC_FOLDFLAG_LINEAFTER_EXPANDED |
8 |
-
Draw below if expanded |
| SC_FOLDFLAG_LINEAFTER_CONTRACTED |
16 |
-
Draw below if not expanded |
| SC_FOLDFLAG_LEVELNUMBERS |
64 |
-
- display hexadecimal fold levels in line margin to aid debugging of
+ | Display hexadecimal fold levels in line margin to aid debugging of
folding. The appearance of this feature may change in the future. |
| SC_FOLDFLAG_LINESTATE |
128 |
-
- display hexadecimal line state in line margin to aid debugging of lexing and folding.
+ | Display hexadecimal line state in line margin to aid debugging of lexing and folding.
May not be used at the same time as SC_FOLDFLAG_LEVELNUMBERS. |
@@ -7173,6 +7182,12 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
+
+ | SC_AUTOMATICFOLD_NONE |
+ 0 |
+ Value with no automatic behaviour. |
+
+
| SC_AUTOMATICFOLD_SHOW |
1 |
@@ -8310,6 +8325,16 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber);
+
+
+ SC_UPDATE_NONE |
+
+ 0x00 |
+
+ Value without any changes. |
+
+
+
SC_UPDATE_CONTENT |
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.
+ 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.
+
+
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
#include
+#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(-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(-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::Allocate(int) {
+std::unique_ptr Surface::Allocate(Technology) {
return std::make_unique();
}
@@ -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
#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(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(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(DirectFunction);
- case SCI_GETDIRECTPOINTER:
+ case Message::GetDirectPointer:
return reinterpret_cast(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(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(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(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 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();
- 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(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(x), static_cast(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(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 surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr 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 surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr 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(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(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 surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
+ std::unique_ptr 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(ptr)->WndProc(iMessage, wParam, lParam);
+ return reinterpret_cast(ptr)->WndProc(static_cast(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(sci->pscin);
- return psci->WndProc(iMessage, wParam, lParam);
+ return psci->WndProc(static_cast(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 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(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(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(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
+// 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
+// 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
+// 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(IndicatorNumbers::Max);
+
+// Functions to manipulate fields from a MarkerOutline
+
+inline int operator<<(int i, MarkerOutline marker) noexcept {
+ return i << static_cast(marker);
+}
+
+// Functions to manipulate fields from a FindOption
+
+constexpr FindOption operator|(FindOption a, FindOption b) noexcept {
+ return static_cast(static_cast(a) | static_cast(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(static_cast(lhs) & static_cast(rhs));
+}
+
+constexpr FoldLevel LevelNumberPart(FoldLevel level) noexcept {
+ return level & FoldLevel::NumberMask;
+}
+
+constexpr int LevelNumber(FoldLevel level) noexcept {
+ return static_cast(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(static_cast(a) | static_cast(b));
+}
+
+// Functions to manipulate fields from a FontQuality
+
+constexpr FontQuality operator&(FontQuality a, FontQuality b) noexcept {
+ return static_cast(static_cast(a) & static_cast(b));
+}
+
+// Functions to manipulate fields from a DocumentOption
+
+constexpr DocumentOption operator|(DocumentOption a, DocumentOption b) noexcept {
+ return static_cast(static_cast(a) | static_cast(b));
+}
+
+// Functions to manipulate fields from a CaretPolicy
+
+constexpr CaretPolicy operator|(CaretPolicy a, CaretPolicy b) noexcept {
+ return static_cast(static_cast(a) | static_cast(b));
+}
+
+// Functions to manipulate fields from a CaretStyle
+
+constexpr CaretStyle operator|(CaretStyle a, CaretStyle b) noexcept {
+ return static_cast(static_cast(a) | static_cast(b));
+}
+
+constexpr CaretStyle operator&(CaretStyle a, CaretStyle b) noexcept {
+ return static_cast(static_cast(a) & static_cast(b));
+}
+
+// Functions to manipulate fields from a LineEndType
+
+constexpr LineEndType operator&(LineEndType a, LineEndType b) noexcept {
+ return static_cast(static_cast(a) & static_cast(b));
+}
+
+// Functions to manipulate fields from a LineCharacterIndexType
+
+constexpr LineCharacterIndexType operator|(LineCharacterIndexType a, LineCharacterIndexType b) noexcept {
+ return static_cast(static_cast(a) | static_cast(b));
+}
+
+// Functions to manipulate fields from a ModificationFlags
+
+constexpr ModificationFlags operator|(ModificationFlags a, ModificationFlags b) noexcept {
+ return static_cast(static_cast(a) | static_cast(b));
+}
+
+constexpr ModificationFlags operator&(ModificationFlags a, ModificationFlags b) noexcept {
+ return static_cast(static_cast(a) & static_cast(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(static_cast(a) | static_cast(b));
+}
+
+// Functions to manipulate fields from a KeyMod
+
+constexpr KeyMod operator|(KeyMod a, KeyMod b) noexcept {
+ return static_cast(static_cast(a) | static_cast(b));
+}
+
+constexpr KeyMod operator&(KeyMod a, KeyMod b) noexcept {
+ return static_cast(static_cast(a) & static_cast(b));
+}
+
+// Test if an enum class value has the bit flag(s) of test set.
+template
+constexpr bool FlagSet(T value, T test) {
+ return (static_cast(value) & static_cast(test)) == static_cast(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
#include
+#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(mh.modificationType), ba, length,
+ mh.linesAdded, mh.line, static_cast(mh.foldLevelNow), static_cast(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(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(pdoc))->AddRef();
@@ -266,11 +270,11 @@ void ScintillaDocument::set_code_page(int code_page) {
}
int ScintillaDocument::get_eol_mode() {
- return (static_cast(pdoc))->eolMode;
+ return static_cast((static_cast(pdoc))->eolMode);
}
void ScintillaDocument::set_eol_mode(int eol_mode) {
- (static_cast(pdoc))->eolMode = eol_mode;
+ (static_cast(pdoc))->eolMode = static_cast(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
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
@@ -42,55 +41,57 @@
#include
#include
-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(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(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::Allocate(int)
+std::unique_ptr Surface::Allocate(Technology)
{
return std::make_unique();
}
@@ -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
@@ -27,9 +29,9 @@
#include
#include
-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(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(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(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
#include
-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
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 surfaceWindow = Surface::Allocate(0);
+ std::unique_ptr 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(DirectFunction);
- case SCI_GETDIRECTPOINTER:
+ case Message::GetDirectPointer:
return reinterpret_cast(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(ptr)->WndProc(iMessage, wParam, lParam);
+ return reinterpret_cast(ptr)->WndProc(static_cast(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
#include
+#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(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
#include
+#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(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(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
- * SC_ORDER_PERFORMSORT: Sort the list alphabetically; start up performance cost for sorting
- * 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
+ * Ordering::PerformSort: Sort the list alphabetically; start up performance cost for sorting
+ * 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
#include
+#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(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
#include
+#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
class LineStartIndex {
@@ -147,15 +149,16 @@ class LineVector : public ILineVector {
PerLine *perLine;
LineStartIndex startsUTF16;
LineStartIndex 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(line);
starts.InsertPartition(lineAsPos, static_cast(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(line));
- if (activeIndices & SC_LINECHARACTERINDEX_UTF32) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf32)) {
startsUTF32.starts.RemovePartition(static_cast(line));
}
- if (activeIndices & SC_LINECHARACTERINDEX_UTF16) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
startsUTF16.starts.RemovePartition(static_cast(line));
}
if (perLine) {
@@ -241,60 +244,60 @@ public:
return starts.PositionFromPartition(static_cast(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(line), static_cast(delta.WidthUTF32()));
}
- if (activeIndices & SC_LINECHARACTERINDEX_UTF16) {
+ if (FlagSet(activeIndices, LineCharacterIndexType::Utf16)) {
startsUTF16.starts.InsertText(static_cast(line), static_cast(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(line));
} else {
return startsUTF16.starts.PositionFromPartition(static_cast(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(startsUTF32.starts.PartitionFromPosition(static_cast(pos)));
} else {
return static_cast(startsUTF16.starts.PartitionFromPosition(static_cast(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>();
@@ -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('\n')] = 1;
eolTable[static_cast('\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(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 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::Check() const noexcept {
}
-namespace Scintilla {
+namespace Scintilla::Internal {
std::unique_ptr 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
#include
+#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
void DecorationList::DeleteLexerDecorations() {
decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(),
[](const std::unique_ptr> &deco) noexcept {
- return deco->Indicator() < INDICATOR_CONTAINER ;
+ return deco->Indicator() < static_cast(Scintilla::IndicatorNumbers::Container);
}), decorationList.end());
current = nullptr;
SetView();
@@ -261,7 +262,7 @@ int DecorationList::AllOnFor(Sci::Position position) const noexcept {
int mask = 0;
for (const std::unique_ptr> &deco : decorationList) {
if (deco->rs.ValueAt(static_cast(position))) {
- if (deco->Indicator() < INDICATOR_IME) {
+ if (deco->Indicator() < static_cast(Scintilla::IndicatorNumbers::Ime)) {
mask |= 1 << deco->Indicator();
}
}
@@ -298,7 +299,7 @@ Sci::Position DecorationList::End(int indicator, Sci::Position position) no
}
-namespace Scintilla {
+namespace Scintilla::Internal {
std::unique_ptr 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
#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(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(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));
}
}
@@ -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(level);
+ mh.foldLevelPrev = static_cast(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(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 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(Status::BadAlloc);
} catch (...) {
- return SC_STATUS_FAILURE;
+ return static_cast(Status::Failure);
}
- return 0;
+ return static_cast(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(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 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 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(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 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 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 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 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
#include
+#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 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
#include
+#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(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(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(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 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 SelectionForeground(const EditModel &model, const View
static ColourRGBA TextBackground(const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
std::optional 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(std::ceil(vsDraw.styles[STYLE_CONTROLCHAR].capitalHeight));
+ const Font *ctrlCharsFont = vsDraw.styles[StyleControlChar].font.get();
+ const int normalCharHeight = static_cast(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 caretlineBack = vsDraw.ElementColour(SC_ELEMENT_CARET_LINE_BACK);
+ const std::optional 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 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(surface->WidthText(fontText, foldDisplayText));
InSelection eolInSelection = InSelection::inNone;
@@ -1238,9 +1241,9 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
const std::optional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret);
const std::optional 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(vsDraw.eolAnnotationVisible & 0xff);
+ const Surface::Ends ends = static_cast(static_cast(vsDraw.eolAnnotationVisible) & 0xff);
const Surface::Ends leftSide = static_cast(static_cast(ends) & 0xf);
const Surface::Ends rightSide = static_cast(static_cast(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(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(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(vsDraw.theEdge.column * vsDraw.spaceWidth);
rcSegment.left = static_cast(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(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((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(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(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(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((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(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 ll;
std::vector phases;
- if ((phasesDraw == PhasesDraw::multiple) && !bufferedDraw) {
+ if ((phasesDraw == PhasesDraw::Multiple) && !bufferedDraw) {
for (DrawPhase phase = DrawPhase::back; phase <= DrawPhase::carets; phase = static_cast(static_cast(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(model.bracesMatchStyle),
static_cast(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((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(vsDraw.theEdge.column * vsDraw.spaceWidth);
rcBeyondEOF.left = static_cast(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(vsDraw.theMultiEdge[edge].column * vsDraw.spaceWidth);
@@ -2463,7 +2466,7 @@ void EditView::FillLineRemainder(Surface *surface, const EditModel &model, const
const std::optional 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(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(surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font.get(),
+ lineNumberWidth = static_cast