feat: Add CStringPointer#ExtractText

- Move CString extensions to their own class.
- Add some words to our dictionary.
This commit is contained in:
Kaz Wolfe 2025-03-24 17:43:49 -07:00
parent ddda4d477d
commit 314c046ec9
No known key found for this signature in database
GPG key ID: 258813F53A16EBB4
3 changed files with 34 additions and 10 deletions

View file

@ -54,6 +54,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EFormat_002ESettingsUpgrade_002EAlignmentTabFillStyleMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bannedplugin/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=clientopcode/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=collectability/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dalamud/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=FFXIV/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Flytext/@EntryIndexedValue">True</s:Boolean>
@ -66,6 +67,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=PLUGINR/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Refilter/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=serveropcode/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=spiritbond/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Universalis/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unsanitized/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Uploaders/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -0,0 +1,32 @@
using InteropGenerator.Runtime;
using Lumina.Text.ReadOnly;
namespace Dalamud.Utility;
/// <summary>
/// A set of helpful utilities for working with <see cref="CStringPointer"/>s from ClientStructs.
/// </summary>
public static class CStringExtensions
{
/// <summary>
/// Convert a CStringPointer to a ReadOnlySeStringSpan.
/// </summary>
/// <param name="ptr">The pointer to convert.</param>
/// <returns>A span.</returns>
public static unsafe ReadOnlySeStringSpan AsReadOnlySeStringSpan(this CStringPointer ptr)
{
return ptr.AsSpan();
}
/// <summary>
/// Extract text from this CStringPointer following <see cref="ReadOnlySeStringSpan.ExtractText()"/>'s rules. Only
/// useful for SeStrings.
/// </summary>
/// <param name="ptr">The CStringPointer to process.</param>
/// <returns>Extracted text.</returns>
public static string ExtractText(this CStringPointer ptr)
{
return ptr.AsReadOnlySeStringSpan().ExtractText();
}
}

View file

@ -228,14 +228,4 @@ public static class SeStringExtensions
var replaced = ReplaceText(new ReadOnlySeString(builder.GetViewAsMemory()), toFind, replacement);
builder.Clear().Append(replaced);
}
/// <summary>
/// Convert a CStringPointer to a ReadOnySeStringSpan.
/// </summary>
/// <param name="ptr">The pointer to convert.</param>
/// <returns>A span.</returns>
public static unsafe ReadOnlySeStringSpan AsReadOnlySeStringSpan(this CStringPointer ptr)
{
return new ReadOnlySeStringSpan(ptr.Value);
}
}