Procházet zdrojové kódy

rtext: added functions for camel case and snake case (reopened due to formatting errors) (#4033)

* rtext: added functions for camel case and snake case

* Update raylib_api.* by CI

* rtext: removed always false comparison

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
pull/4039/head
IoIxD před 7 měsíci
odevzdal GitHub
rodič
revize
39f12859dc
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: B5690EEEBB952194
6 změnil soubory, kde provedl 265 přidání a 143 odebrání
  1. +22
    -0
      parser/output/raylib_api.json
  2. +16
    -0
      parser/output/raylib_api.lua
  3. +152
    -142
      parser/output/raylib_api.txt
  4. +7
    -1
      parser/output/raylib_api.xml
  5. +3
    -0
      src/raylib.h
  6. +65
    -0
      src/rtext.c

+ 22
- 0
parser/output/raylib_api.json Zobrazit soubor

@ -9479,6 +9479,28 @@
}
]
},
{
"name": "TextToSnake",
"description": "Get Snake case notation version of provided string",
"returnType": "const char *",
"params": [
{
"type": "const char *",
"name": "text"
}
]
},
{
"name": "TextToCamel",
"description": "Get Camel case notation version of provided string",
"returnType": "const char *",
"params": [
{
"type": "const char *",
"name": "text"
}
]
},
{
"name": "TextToInteger",
"description": "Get integer value from text (negative values not supported)",

+ 16
- 0
parser/output/raylib_api.lua Zobrazit soubor

@ -6776,6 +6776,22 @@ return {
{type = "const char *", name = "text"}
}
},
{
name = "TextToSnake",
description = "Get Snake case notation version of provided string",
returnType = "const char *",
params = {
{type = "const char *", name = "text"}
}
},
{
name = "TextToCamel",
description = "Get Camel case notation version of provided string",
returnType = "const char *",
params = {
{type = "const char *", name = "text"}
}
},
{
name = "TextToInteger",
description = "Get integer value from text (negative values not supported)",

+ 152
- 142
parser/output/raylib_api.txt
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 7
- 1
parser/output/raylib_api.xml Zobrazit soubor

@ -670,7 +670,7 @@
<Param type="unsigned int" name="frames" desc="" />
</Callback>
</Callbacks>
<Functions count="564">
<Functions count="566">
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
<Param type="int" name="width" desc="" />
<Param type="int" name="height" desc="" />
@ -2405,6 +2405,12 @@
<Function name="TextToPascal" retType="const char *" paramCount="1" desc="Get Pascal case notation version of provided string">
<Param type="const char *" name="text" desc="" />
</Function>
<Function name="TextToSnake" retType="const char *" paramCount="1" desc="Get Snake case notation version of provided string">
<Param type="const char *" name="text" desc="" />
</Function>
<Function name="TextToCamel" retType="const char *" paramCount="1" desc="Get Camel case notation version of provided string">
<Param type="const char *" name="text" desc="" />
</Function>
<Function name="TextToInteger" retType="int" paramCount="1" desc="Get integer value from text (negative values not supported)">
<Param type="const char *" name="text" desc="" />
</Function>

+ 3
- 0
src/raylib.h Zobrazit soubor

@ -1489,6 +1489,9 @@ RLAPI int TextFindIndex(const char *text, const char *find);
RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string
RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string
RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string
RLAPI const char *TextToSnake(const char *text); // Get Snake case notation version of provided string
RLAPI const char *TextToCamel(const char *text); // Get Camel case notation version of provided string
RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported)
RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported)

+ 65
- 0
src/rtext.c Zobrazit soubor

@ -1786,6 +1786,71 @@ const char *TextToPascal(const char *text)
return buffer;
}
// Get snake case notation version of provided string
// WARNING: Limited functionality, only basic characters set
const char *TextToSnake(const char *text)
{
static char buffer[MAX_TEXT_BUFFER_LENGTH] = {0};
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
if (text != NULL)
{
// Check for next separator to upper case another character
for (int i = 0, j = 0; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[j] != '\0'); i++, j++)
{
if ((text[j] >= 'A') && (text[j] <= 'Z'))
{
if (i >= 1)
{
buffer[i] = '_';
i++;
}
buffer[i] = text[j] + 32;
}
else
{
buffer[i] = text[j];
}
}
}
return buffer;
}
// Get Camel case notation version of provided string
// WARNING: Limited functionality, only basic characters set
const char *TextToCamel(const char *text)
{
static char buffer[MAX_TEXT_BUFFER_LENGTH] = {0};
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
if (text != NULL)
{
// Lower case first character
if ((text[0] >= 'A') && (text[0] <= 'Z'))
buffer[0] = text[0] + 32;
else
buffer[0] = text[0];
// Check for next separator to upper case another character
for (int i = 1, j = 1; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[j] != '\0'); i++, j++)
{
if (text[j] != '_')
buffer[i] = text[j];
else
{
j++;
if ((text[j] >= 'a') && (text[j] <= 'z'))
{
buffer[i] = text[j] - 32;
}
}
}
}
return buffer;
}
// Encode text codepoint into UTF-8 text
// REQUIRES: memcpy()
// WARNING: Allocated memory must be manually freed

Načítá se…
Zrušit
Uložit