Skip to content

Commit 92bad0a

Browse files
committed
Upgrade Scintilla from 4.1.4 to 4.2.0
Fix #5822
1 parent 69da7a7 commit 92bad0a

File tree

127 files changed

+11170
-4916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+11170
-4916
lines changed
Binary file not shown.

scintilla/boostregex/BoostRegExSearch.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "Decoration.h"
3030
#include "ILexer.h"
3131
#include "CaseFolder.h"
32+
#include "CharacterCategory.h"
3233
#include "Document.h"
3334
#include "UniConversion.h"
3435
#include "UTF8DocumentIterator.h"

scintilla/cocoa/InfoBar.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt).
1111
*/
1212

13+
#include <cmath>
14+
1315
#import "InfoBar.h"
1416

1517
//--------------------------------------------------------------------------------------------------
@@ -33,7 +35,7 @@ - (NSRect) drawingRectForBounds: (NSRect) theRect {
3335
CGFloat heightDelta = newRect.size.height - textSize.height;
3436
if (heightDelta > 0) {
3537
newRect.size.height -= heightDelta;
36-
newRect.origin.y += ceil(heightDelta / 2);
38+
newRect.origin.y += std::ceil(heightDelta / 2);
3739
}
3840
}
3941

@@ -349,7 +351,7 @@ - (void) setScaleFactor: (float) newScaleFactor adjustPopup: (BOOL) flag {
349351

350352
// We only work with some preset zoom values. If the given value does not correspond
351353
// to one then show no selection.
352-
while (count < numberOfDefaultItems && (fabs(newScaleFactor - DefaultScaleMenuFactors[count]) > 0.07))
354+
while (count < numberOfDefaultItems && (std::abs(newScaleFactor - DefaultScaleMenuFactors[count]) > 0.07))
353355
count++;
354356
if (count == numberOfDefaultItems)
355357
[mZoomPopup selectItemAtIndex: -1];

scintilla/cocoa/PlatCocoa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class SurfaceImpl : public Surface {
8080
void PenColour(ColourDesired fore) override;
8181

8282
/** Returns a CGImageRef that represents the surface. Returns NULL if this is not possible. */
83-
CGImageRef GetImage();
83+
CGImageRef CreateImage();
8484
void CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, PRectangle dstRect);
8585

8686
int LogPixelsY() override;

scintilla/cocoa/PlatCocoa.mm

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <cassert>
1818
#include <cstring>
1919
#include <cstdio>
20+
#include <cmath>
2021

2122
#include <stdexcept>
2223
#include <string_view>
@@ -251,7 +252,7 @@ void AddToIntervalVector(std::vector<Interval> &vi, XYPOSITION left, XYPOSITION
251252
vi.push_back(interval);
252253
} else {
253254
Interval &last = vi.back();
254-
if (fabs(last.right-interval.left) < 0.01) {
255+
if (std::abs(last.right-interval.left) < 0.01) {
255256
// If new left is very close to previous right then extend last item
256257
last.right = interval.right;
257258
} else {
@@ -482,8 +483,8 @@ void GetPositions(CTLineRef line, std::vector<CGFloat> &positions) {
482483

483484
//--------------------------------------------------------------------------------------------------
484485

485-
CGImageRef SurfaceImpl::GetImage() {
486-
// For now, assume that GetImage can only be called on PixMap surfaces.
486+
CGImageRef SurfaceImpl::CreateImage() {
487+
// For now, assume that CreateImage can only be called on PixMap surfaces.
487488
if (!bitmapData)
488489
return NULL;
489490

@@ -628,8 +629,8 @@ void GetPositions(CTLineRef line, std::vector<CGFloat> &positions) {
628629
if (gc) {
629630
FillColour(back);
630631
// Snap rectangle boundaries to nearest int
631-
rc.left = lround(rc.left);
632-
rc.right = lround(rc.right);
632+
rc.left = std::round(rc.left);
633+
rc.right = std::round(rc.right);
633634
CGRect rect = PRectangleToCGRect(rc);
634635
CGContextFillRect(gc, rect);
635636
}
@@ -654,7 +655,7 @@ static void releaseImageRefCallback(void *info) {
654655
SurfaceImpl &patternSurface = static_cast<SurfaceImpl &>(surfacePattern);
655656

656657
// For now, assume that copy can only be called on PixMap surfaces. Shows up black.
657-
CGImageRef image = patternSurface.GetImage();
658+
CGImageRef image = patternSurface.CreateImage();
658659
if (image == NULL) {
659660
FillRectangle(rc, ColourDesired(0));
660661
return;
@@ -805,8 +806,8 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz
805806
ColourDesired outline, int alphaOutline, int /*flags*/) {
806807
if (gc) {
807808
// Snap rectangle boundaries to nearest int
808-
rc.left = lround(rc.left);
809-
rc.right = lround(rc.right);
809+
rc.left = std::round(rc.left);
810+
rc.right = std::round(rc.right);
810811
// Set the Fill color to match
811812
CGContextSetRGBFillColor(gc, fill.GetRed() / 255.0, fill.GetGreen() / 255.0, fill.GetBlue() / 255.0, alphaFill / 255.0);
812813
CGContextSetRGBStrokeColor(gc, outline.GetRed() / 255.0, outline.GetGreen() / 255.0, outline.GetBlue() / 255.0, alphaOutline / 255.0);
@@ -969,7 +970,7 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char
969970

970971
void SurfaceImpl::CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, PRectangle dstRect) {
971972
SurfaceImpl &source = static_cast<SurfaceImpl &>(surfaceSource);
972-
CGImageRef image = source.GetImage();
973+
CGImageRef image = source.CreateImage();
973974

974975
CGRect src = PRectangleToCGRect(srcRect);
975976
CGRect dst = PRectangleToCGRect(dstRect);
@@ -1001,7 +1002,7 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char
10011002
SurfaceImpl &source = static_cast<SurfaceImpl &>(surfaceSource);
10021003

10031004
// Get the CGImageRef
1004-
CGImageRef image = source.GetImage();
1005+
CGImageRef image = source.CreateImage();
10051006
// If we could not get an image reference, fill the rectangle black
10061007
if (image == NULL) {
10071008
FillRectangle(rc, ColourDesired(0));
@@ -1115,7 +1116,7 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) {
11151116
CGColorRef color = CGColorCreateGenericRGB(colour.GetRed()/255.0, colour.GetGreen()/255.0, colour.GetBlue()/255.0, 1.0);
11161117

11171118
QuartzTextStyle *style = TextStyleFromFont(font_);
1118-
style->setCTStyleColor(color);
1119+
style->setCTStyleColour(color);
11191120

11201121
CGColorRelease(color);
11211122

@@ -1232,7 +1233,7 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) {
12321233

12331234
XYPOSITION width = WidthText(font_, sizeString);
12341235

1235-
return round(width / strlen(sizeString));
1236+
return std::round(width / strlen(sizeString));
12361237
}
12371238

12381239
void SurfaceImpl::SetClip(PRectangle rc) {
@@ -1470,7 +1471,7 @@ PRectangle rcMonitor(rcWork.left - rcPosition.left,
14701471
SurfaceImpl *surfaceIXPM = static_cast<SurfaceImpl *>(surfaceXPM.get());
14711472
CGContextClearRect(surfaceIXPM->GetContext(), CGRectMake(0, 0, width, height));
14721473
pxpm->Draw(surfaceXPM.get(), rcxpm);
1473-
CGImageRef imageRef = surfaceIXPM->GetImage();
1474+
CGImageRef imageRef = surfaceIXPM->CreateImage();
14741475
img = [[NSImage alloc] initWithCGImage: imageRef size: NSZeroSize];
14751476
CGImageRelease(imageRef);
14761477
}
@@ -1750,7 +1751,7 @@ void SetDelegate(IListBoxDelegate *lbDelegate) override {
17501751
font.SetID(new QuartzTextStyle(*style));
17511752
NSFont *pfont = (__bridge NSFont *)style->getFontRef();
17521753
[colText.dataCell setFont: pfont];
1753-
CGFloat itemHeight = ceil(pfont.boundingRectForFont.size.height);
1754+
CGFloat itemHeight = std::ceil(pfont.boundingRectForFont.size.height);
17541755
table.rowHeight = itemHeight;
17551756
}
17561757

scintilla/cocoa/QuartzTextStyle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class QuartzTextStyle {
4747
return styleDict;
4848
}
4949

50-
void setCTStyleColor(CGColor *inColor) {
51-
CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, inColor);
50+
void setCTStyleColour(CGColor *inColour) {
51+
CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, inColour);
5252
}
5353

5454
float getAscent() const {

scintilla/cocoa/ScintillaCocoa.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "PropSetSimple.h"
3333
#endif
3434

35+
#include "CharacterCategory.h"
3536
#include "Position.h"
3637
#include "UniqueString.h"
3738
#include "SplitVector.h"
@@ -196,7 +197,7 @@ class ScintillaCocoa : public ScintillaBase {
196197
void ObserverRemove();
197198
void IdleWork() override;
198199
void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) override;
199-
ptrdiff_t InsertText(NSString *input);
200+
ptrdiff_t InsertText(NSString *input, CharacterSource charSource);
200201
NSRange PositionsFromCharacters(NSRange rangeCharacters) const;
201202
NSRange CharactersFromPositions(NSRange rangePositions) const;
202203
NSString *RangeTextAsString(NSRange rangePositions) const;

scintilla/cocoa/ScintillaCocoa.mm

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt).
1515
*/
1616

17+
#include <cmath>
18+
1719
#include <string_view>
1820
#include <vector>
1921

@@ -316,7 +318,7 @@ - (id) init: (void *) target {
316318
// main thread). We need that later for idle event processing.
317319
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
318320
notificationQueue = [[NSNotificationQueue alloc] initWithNotificationCenter: center];
319-
[center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: nil];
321+
[center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: self];
320322
}
321323
return self;
322324
}
@@ -818,7 +820,7 @@ sptr_t scintilla_send_message(void *sci, unsigned int iMessage, uptr_t wParam, s
818820
*/
819821

820822
bool SupportAnimatedFind() {
821-
return floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_12;
823+
return std::floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_12;
822824
}
823825

824826
}
@@ -1407,7 +1409,7 @@ - (void) pasteboard: (NSPasteboard *) pasteboard item: (NSPasteboardItem *) item
14071409
// the full rectangle which may include non-selected text.
14081410

14091411
NSBitmapImageRep *bitmap = NULL;
1410-
CGImageRef imagePixmap = pixmap.GetImage();
1412+
CGImageRef imagePixmap = pixmap.CreateImage();
14111413
if (imagePixmap)
14121414
bitmap = [[NSBitmapImageRep alloc] initWithCGImage: imagePixmap];
14131415
CGImageRelease(imagePixmap);
@@ -2173,26 +2175,39 @@ static int TranslateModifierFlags(NSUInteger modifiers) {
21732175
/**
21742176
* Used to insert already processed text provided by the Cocoa text input system.
21752177
*/
2176-
ptrdiff_t ScintillaCocoa::InsertText(NSString *input) {
2177-
CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
2178-
vs.styles[STYLE_DEFAULT].characterSet);
2179-
std::string encoded = EncodedBytesString((__bridge CFStringRef)input, encoding);
2180-
2181-
if (encoded.length() > 0) {
2182-
if (encoding == kCFStringEncodingUTF8) {
2183-
// There may be multiple characters in input so loop over them
2184-
std::string_view sv = encoded;
2185-
while (sv.length()) {
2186-
const unsigned char leadByte = sv[0];
2187-
const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte];
2188-
AddCharUTF(sv.data(), bytesInCharacter, false);
2189-
sv.remove_prefix(bytesInCharacter);
2190-
}
2191-
} else {
2192-
AddCharUTF(encoded.c_str(), static_cast<unsigned int>(encoded.length()), false);
2178+
ptrdiff_t ScintillaCocoa::InsertText(NSString *input, CharacterSource charSource) {
2179+
if ([input length] == 0) {
2180+
return 0;
2181+
}
2182+
2183+
// There may be multiple characters in input so loop over them
2184+
if (IsUnicodeMode()) {
2185+
// There may be non-BMP characters as 2 elements in NSString so
2186+
// convert to UTF-8 and use UTF8BytesOfLead.
2187+
std::string encoded = EncodedBytesString((__bridge CFStringRef)input,
2188+
kCFStringEncodingUTF8);
2189+
std::string_view sv = encoded;
2190+
while (sv.length()) {
2191+
const unsigned char leadByte = sv[0];
2192+
const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte];
2193+
InsertCharacter(sv.substr(0, bytesInCharacter), charSource);
2194+
sv.remove_prefix(bytesInCharacter);
2195+
}
2196+
return encoded.length();
2197+
} else {
2198+
const CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(),
2199+
vs.styles[STYLE_DEFAULT].characterSet);
2200+
ptrdiff_t lengthInserted = 0;
2201+
for (NSInteger i = 0; i < [input length]; i++) {
2202+
NSString *character = [input substringWithRange:NSMakeRange(i, 1)];
2203+
std::string encoded = EncodedBytesString((__bridge CFStringRef)character,
2204+
encoding);
2205+
lengthInserted += encoded.length();
2206+
InsertCharacter(encoded, charSource);
21932207
}
2208+
2209+
return lengthInserted;
21942210
}
2195-
return encoded.length();
21962211
}
21972212

21982213
//--------------------------------------------------------------------------------------------------
@@ -2272,7 +2287,7 @@ static int TranslateModifierFlags(NSUInteger modifiers) {
22722287
*/
22732288
void ScintillaCocoa::CompositionCommit() {
22742289
pdoc->TentativeCommit();
2275-
pdoc->DecorationSetCurrentIndicator(INDIC_IME);
2290+
pdoc->DecorationSetCurrentIndicator(INDICATOR_IME);
22762291
pdoc->DecorationFillRange(0, 0, pdoc->Length());
22772292
}
22782293

@@ -2486,7 +2501,7 @@ unsigned int TimeOfEvent(NSEvent *event) {
24862501
layerFindIndicator = [[FindHighlightLayer alloc] init];
24872502
[content setWantsLayer: YES];
24882503
layerFindIndicator.geometryFlipped = content.layer.geometryFlipped;
2489-
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8) {
2504+
if (std::floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8) {
24902505
// Content layer is unflipped on 10.9, but the indicator shows wrong unless flipped
24912506
layerFindIndicator.geometryFlipped = YES;
24922507
}

scintilla/cocoa/ScintillaFramework/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>FMWK</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>4.1.4</string>
20+
<string>4.2.0</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>4.1.4</string>
24+
<string>4.2.0</string>
2525
<key>NSPrincipalClass</key>
2626
<string></string>
2727
</dict>

0 commit comments

Comments
 (0)