From 2f701a63381887e535b20f30a46b5babbe895926 Mon Sep 17 00:00:00 2001 From: Apache <93100547+Apachedrag427@users.noreply.github.com> Date: Thu, 16 Feb 2023 07:37:13 -0600 Subject: [PATCH] Add machine.title length checks (#4) Setting an empty string resets the title, setting a string longer than 256 characters truncates it. --- Capy64/Runtime/Libraries/Machine.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Capy64/Runtime/Libraries/Machine.cs b/Capy64/Runtime/Libraries/Machine.cs index 8810881..78f3426 100644 --- a/Capy64/Runtime/Libraries/Machine.cs +++ b/Capy64/Runtime/Libraries/Machine.cs @@ -1,4 +1,4 @@ -// This file is part of Capy64 - https://github.com/Capy64/Capy64 +// This file is part of Capy64 - https://github.com/Capy64/Capy64 // Copyright 2023 Alessandro "AlexDevs" Proto // // Licensed under the Apache License, Version 2.0 (the "License"). @@ -103,6 +103,13 @@ public class Machine : IPlugin if (!L.IsNoneOrNil(1)) { var newTitle = L.CheckString(1); + + if (string.IsNullOrEmpty(newTitle)) + { + newTitle = "Capy64 " + Capy64.Version; + } + + newTitle = newTitle[..Math.Min(newTitle.Length, 256)]; Capy64.Instance.Window.Title = newTitle; }