From 96990d94ff80d64b82063952bf32db662deb1d32 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Fri, 31 Jan 2020 18:30:57 -0500 Subject: [PATCH] osx stuff --- dub.json | 2 ++ minigui.d | 6 +++++- simpledisplay.d | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dub.json b/dub.json index 812dd0f..a6992b9 100644 --- a/dub.json +++ b/dub.json @@ -36,6 +36,8 @@ "targetType": "library", "importPaths": ["."], "dflags": ["-mv=arsd.simpledisplay=simpledisplay.d"], + "versions-osx": [ "OSXCocoa", "allow_unimplemented_features", "without_opengl" ], + "lflags-osx": ["-framework", "Cocoa"], "dependencies": {"arsd-official:color_base":"*"}, "configurations": [ { diff --git a/minigui.d b/minigui.d index 740ace6..900eca0 100644 --- a/minigui.d +++ b/minigui.d @@ -5721,7 +5721,8 @@ abstract class EditableTextWidget : EditableTextWidgetParent { else version(custom_widgets) { // FIXME - Timer caretTimer; + static if(SimpledisplayTimerAvailable) + Timer caretTimer; TextLayout textLayout; void setupCustomTextEditing() { @@ -5801,6 +5802,7 @@ abstract class EditableTextWidget : EditableTextWidgetParent { auto painter = this.draw(); textLayout.drawCaret(painter); + static if(SimpledisplayTimerAvailable) if(caretTimer) { caretTimer.destroy(); caretTimer = null; @@ -5812,6 +5814,7 @@ abstract class EditableTextWidget : EditableTextWidgetParent { blinkingCaret = false; // if on a remote connection, don't waste bandwidth on an expendable blink if(blinkingCaret) + static if(SimpledisplayTimerAvailable) caretTimer = new Timer(500, { if(parentWindow.win.closed) { caretTimer.destroy(); @@ -5833,6 +5836,7 @@ abstract class EditableTextWidget : EditableTextWidgetParent { version(custom_widgets) { auto painter = this.draw(); textLayout.eraseCaret(painter); + static if(SimpledisplayTimerAvailable) if(caretTimer) { caretTimer.destroy(); caretTimer = null; diff --git a/simpledisplay.d b/simpledisplay.d index 127e419..e4f711f 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -809,6 +809,15 @@ unittest { } } +/* +version(OSX) { + version=without_opengl; + version=allow_unimplemented_features; + version=OSXCocoa; + pragma(linkerDirective, "-framework Cocoa"); +} +*/ + version(without_opengl) { enum SdpyIsUsingIVGLBinds = false; } else /*version(Posix)*/ { @@ -992,6 +1001,11 @@ version(Windows) version(linux) version = with_timer; +version(with_timer) + enum bool SimpledisplayTimerAvailable = true; +else + enum bool SimpledisplayTimerAvailable = false; + /// If you have to get down and dirty with implementation details, this helps figure out if Windows is available you can `static if(UsingSimpledisplayWindows) ...` more reliably than `version()` because `version` is module-local. version(Windows) enum bool UsingSimpledisplayWindows = true;