1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

UTF8 changes to consistently use int8 for codepoint widths

This commit is contained in:
Brian Fiete 2024-10-26 06:25:39 -04:00
parent 0e2f49fd12
commit 1226810984
3 changed files with 7 additions and 7 deletions

View file

@ -516,7 +516,7 @@ namespace Beefy.theme.dark
int underlinePos = label.IndexOf('&'); int underlinePos = label.IndexOf('&');
if (underlinePos == -1) if (underlinePos == -1)
return false; return false;
char32 underlineC = label.GetChar32(underlinePos + 1).0; char32 underlineC = label.GetChar32(underlinePos + 1).c;
underlineC = underlineC.ToUpper; underlineC = underlineC.ToUpper;
return ((char32)keyCode == underlineC); return ((char32)keyCode == underlineC);
} }
@ -530,7 +530,7 @@ namespace Beefy.theme.dark
label.Append(str, 0, underlinePos); label.Append(str, 0, underlinePos);
float underlineX = g.mFont.GetWidth(label); 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); float underlineWidth = g.mFont.GetWidth(underlineC);
FontMetrics fm = .(); FontMetrics fm = .();

View file

@ -2799,7 +2799,7 @@ namespace System
return (c32, idx, len); return (c32, idx, len);
} }
public (int startIdx, int length) GetCodePointSpan(int idx) public (int startIdx, int8 length) GetCodePointSpan(int idx)
{ {
char8* ptr = Ptr; char8* ptr = Ptr;
int startIdx = idx; int startIdx = idx;
@ -4178,7 +4178,7 @@ namespace System
return .(this)[range]; return .(this)[range];
} }
public (char32, int) GetChar32(int idx) public (char32 c, int8 length) GetChar32(int idx)
{ {
Debug.Assert((uint)idx < (uint)mLength); Debug.Assert((uint)idx < (uint)mLength);
char8* ptr = Ptr; char8* ptr = Ptr;
@ -4190,7 +4190,7 @@ namespace System
return UTF8.Decode(ptr + idx, mLength - idx); 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); Debug.Assert((uint)idx < (uint)mLength);
char8* ptr = Ptr; char8* ptr = Ptr;

View file

@ -34,13 +34,13 @@ namespace System.Text
return 5; return 5;
} }
public static int GetDecodedLength(char8* buf) public static int8 GetDecodedLength(char8* buf)
{ {
char32 c = *buf; char32 c = *buf;
return UTF8.sTrailingBytesForUTF8[c] + 1; return UTF8.sTrailingBytesForUTF8[c] + 1;
} }
public static int GetDecodedLength(char8 firstChar) public static int8 GetDecodedLength(char8 firstChar)
{ {
return UTF8.sTrailingBytesForUTF8[firstChar] + 1; return UTF8.sTrailingBytesForUTF8[firstChar] + 1;
} }