mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-11 01:37:24 +01:00
feat: Add CStringPointer#ExtractText
- Move CString extensions to their own class. - Add some words to our dictionary.
This commit is contained in:
parent
ddda4d477d
commit
314c046ec9
3 changed files with 34 additions and 10 deletions
|
|
@ -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>
|
||||
|
|
|
|||
32
Dalamud/Utility/CStringExtensions.cs
Normal file
32
Dalamud/Utility/CStringExtensions.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue