From 1226810984d4970fc9f0c8bc0c0bde7149f797c9 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sat, 26 Oct 2024 06:25:39 -0400 Subject: [PATCH] UTF8 changes to consistently use int8 for codepoint widths --- BeefLibs/Beefy2D/src/theme/dark/DarkTheme.bf | 4 ++-- BeefLibs/corlib/src/String.bf | 6 +++--- BeefLibs/corlib/src/Text/UTF8.bf | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkTheme.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkTheme.bf index 98e59f1a..97225b72 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkTheme.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkTheme.bf @@ -516,7 +516,7 @@ namespace Beefy.theme.dark int underlinePos = label.IndexOf('&'); if (underlinePos == -1) return false; - char32 underlineC = label.GetChar32(underlinePos + 1).0; + char32 underlineC = label.GetChar32(underlinePos + 1).c; underlineC = underlineC.ToUpper; return ((char32)keyCode == underlineC); } @@ -530,7 +530,7 @@ namespace Beefy.theme.dark label.Append(str, 0, underlinePos); float underlineX = g.mFont.GetWidth(label); - char32 underlineC = str.GetChar32(underlinePos + 1).0; + char32 underlineC = str.GetChar32(underlinePos + 1).c; float underlineWidth = g.mFont.GetWidth(underlineC); FontMetrics fm = .(); diff --git a/BeefLibs/corlib/src/String.bf b/BeefLibs/corlib/src/String.bf index 31cd66f7..e029e8d5 100644 --- a/BeefLibs/corlib/src/String.bf +++ b/BeefLibs/corlib/src/String.bf @@ -2799,7 +2799,7 @@ namespace System return (c32, idx, len); } - public (int startIdx, int length) GetCodePointSpan(int idx) + public (int startIdx, int8 length) GetCodePointSpan(int idx) { char8* ptr = Ptr; int startIdx = idx; @@ -4178,7 +4178,7 @@ namespace System return .(this)[range]; } - public (char32, int) GetChar32(int idx) + public (char32 c, int8 length) GetChar32(int idx) { Debug.Assert((uint)idx < (uint)mLength); char8* ptr = Ptr; @@ -4190,7 +4190,7 @@ namespace System return UTF8.Decode(ptr + idx, mLength - idx); } - public (char32, int, int) GetChar32WithBacktrack(int idx) + public (char32 c, int idx, int8 length) GetChar32WithBacktrack(int idx) { Debug.Assert((uint)idx < (uint)mLength); char8* ptr = Ptr; diff --git a/BeefLibs/corlib/src/Text/UTF8.bf b/BeefLibs/corlib/src/Text/UTF8.bf index 0dce24ae..142b352a 100644 --- a/BeefLibs/corlib/src/Text/UTF8.bf +++ b/BeefLibs/corlib/src/Text/UTF8.bf @@ -34,13 +34,13 @@ namespace System.Text return 5; } - public static int GetDecodedLength(char8* buf) + public static int8 GetDecodedLength(char8* buf) { char32 c = *buf; return UTF8.sTrailingBytesForUTF8[c] + 1; } - public static int GetDecodedLength(char8 firstChar) + public static int8 GetDecodedLength(char8 firstChar) { return UTF8.sTrailingBytesForUTF8[firstChar] + 1; }