aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa/ScintillaCocoa.mm
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2023-02-24 10:43:05 +1100
committerNeil Hodgson <nyamatongwe@gmail.com>2023-02-24 10:43:05 +1100
commita00f308a11b90a0edb1bd9a71a78612e0463fe83 (patch)
treec97e63f5fb0c24833e81b7d634e0dc315d3ad822 /cocoa/ScintillaCocoa.mm
parent778dc10b3ee2f621d8548b1d074429c44bd3ae62 (diff)
downloadscintilla-mirror-a00f308a11b90a0edb1bd9a71a78612e0463fe83.tar.gz
Replace deprecated graphicsPort API with current CGContext.
Diffstat (limited to 'cocoa/ScintillaCocoa.mm')
-rw-r--r--cocoa/ScintillaCocoa.mm18
1 files changed, 16 insertions, 2 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 884a976d0..3d4a0f622 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -399,6 +399,20 @@ const CGFloat paddingHighlightY = 2;
@end
+//----------------- CGContextCurrent ---------------------------------------------------------------
+
+CGContextRef Scintilla::Internal::CGContextCurrent() {
+ if (@available(macOS 10.10, *)) {
+ return [NSGraphicsContext currentContext].CGContext;
+ } else {
+ // Use old deprecated API
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ return static_cast<CGContextRef>([NSGraphicsContext currentContext].graphicsPort);
+#pragma clang diagnostic pop
+ }
+}
+
//----------------- ScintillaCocoa -----------------------------------------------------------------
ScintillaCocoa::ScintillaCocoa(ScintillaView *sciView_, SCIContentView *viewContent, SCIMarginView *viewMargin) {
@@ -1132,7 +1146,7 @@ void ScintillaCocoa::CTPaint(void *gc, NSRect rc) {
- (void) drawRect: (NSRect) needsDisplayInRect {
if (sci) {
- CGContextRef context = (CGContextRef) [NSGraphicsContext currentContext].graphicsPort;
+ CGContextRef context = CGContextCurrent();
sci->CTPaint(context, needsDisplayInRect);
}
}
@@ -1873,7 +1887,7 @@ bool ScintillaCocoa::SyncPaint(void *gc, PRectangle rc) {
* Paint the margin into the SCIMarginView space.
*/
void ScintillaCocoa::PaintMargin(NSRect aRect) {
- CGContextRef gc = (CGContextRef) [NSGraphicsContext currentContext].graphicsPort;
+ CGContextRef gc = CGContextCurrent();
PRectangle rc = NSRectToPRectangle(aRect);
rcPaint = rc;