From a4bf85294ebdbf440e7c026c395e9677fe454f95 Mon Sep 17 00:00:00 2001 From: ChrisDill Date: Mon, 14 Feb 2022 12:01:59 +0000 Subject: [PATCH] Readd string functions --- Raylib-cs/interop/Raylib.cs | 90 +++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 24 deletions(-) diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index 0072102..8f848c8 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -1482,7 +1482,7 @@ namespace Raylib_cs public static extern void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale, Color tint); - // Text misc. functions + // Text font info functions /// Measure string width for default font [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1504,30 +1504,8 @@ namespace Raylib_cs [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern Rectangle GetGlyphAtlasRec(Font font, int codepoint); - // Text strings management functions - // NOTE: Some strings allocate memory internally for returned strings, just be careful! - /// Text formatting with variables (sprintf style) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextFormat(sbyte* text); - - /// Get a piece of a text string - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextSubtext(sbyte* text, int position, int length); - - /// Append text at specific position and move cursor! - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void TextAppend(sbyte* text, sbyte* append, int* position); - - /// Get Pascal case notation version of provided string - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern sbyte* TextToPascal(sbyte* text); - - /// Get integer value from text (negative values not supported) - [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern int TextToInteger(sbyte* text); - - // UTF8 text strings management functions + // Text codepoints management functions (unicode characters) /// Get all codepoints in a string, codepoints count returned by parameters [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] @@ -1554,6 +1532,70 @@ namespace Raylib_cs public static extern sbyte* TextCodepointsToUTF8(int* codepoints, int length); + // Text strings management functions (no UTF-8 strings, only byte chars) + // NOTE: Some strings allocate memory internally for returned strings, just be careful! + + // Copy one string to another, returns bytes copied + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TextCopy(char* dst, sbyte* src); + + /// Check if two text string are equal + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern bool TextIsEqual(sbyte* text1, sbyte* text2); + + /// Get text length, checks for '\0' ending + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern uint TextLength(sbyte* text); + + /// Text formatting with variables (sprintf style) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextFormat(sbyte* text); + + /// Get a piece of a text string + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextSubtext(sbyte* text, int position, int length); + + /// Replace text string (WARNING: memory must be freed!) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern char* TextReplace(char* text, sbyte* replace, sbyte* by); + + /// Insert text in a position (WARNING: memory must be freed!) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern char* TextInsert(sbyte* text, sbyte* insert, int position); + + /// Join text strings with delimiter + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextJoin(sbyte** textList, int count, sbyte* delimiter); + + /// Split text into multiple strings + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte** TextSplit(sbyte* text, char delimiter, int* count); + + /// Append text at specific position and move cursor! + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void TextAppend(sbyte* text, sbyte* append, int* position); + + /// Find first text occurrence within a string + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TextFindIndex(sbyte* text, sbyte* find); + + /// Get upper case version of provided string + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextToUpper(sbyte* text); + + /// Get lower case version of provided string + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextToLower(sbyte* text); + + /// Get Pascal case notation version of provided string + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern sbyte* TextToPascal(sbyte* text); + + /// Get integer value from text (negative values not supported) + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int TextToInteger(sbyte* text); + + //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) //------------------------------------------------------------------------------------