From 001ce2f626402e575f0ea4af8d227fbaa5237a54 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sat, 18 Feb 2023 20:33:25 +0100 Subject: [PATCH] Return nil if clipboard does not contain any text --- Capy64/Runtime/Libraries/Machine.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Capy64/Runtime/Libraries/Machine.cs b/Capy64/Runtime/Libraries/Machine.cs index a245181..6f8341e 100644 --- a/Capy64/Runtime/Libraries/Machine.cs +++ b/Capy64/Runtime/Libraries/Machine.cs @@ -110,7 +110,7 @@ public class Machine : IComponent if (!L.IsNoneOrNil(1)) { var newTitle = L.CheckString(1); - + if (string.IsNullOrEmpty(newTitle)) { newTitle = "Capy64 " + Capy64.Version; @@ -130,7 +130,10 @@ public class Machine : IComponent { var L = Lua.FromIntPtr(state); - L.PushString(SDL.GetClipboardText()); + if (SDL.HasClipboardText()) + L.PushString(SDL.GetClipboardText()); + else + L.PushNil(); return 1; }