Add machine.title length checks (#4)

Setting an empty string resets the title, setting a string longer than 256 characters truncates it.
This commit is contained in:
Apache 2023-02-16 07:37:13 -06:00 committed by GitHub
parent 5045fa757c
commit 2f701a6338
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}