Review some defines
This commit is contained in:
parent
ea70c47a1a
commit
ca92f43c27
1 changed files with 25 additions and 9 deletions
34
src/text.c
34
src/text.c
|
@ -10,6 +10,15 @@
|
||||||
* supported by default, to remove support, just comment unrequired #define in this module
|
* supported by default, to remove support, just comment unrequired #define in this module
|
||||||
*
|
*
|
||||||
* #define SUPPORT_DEFAULT_FONT
|
* #define SUPPORT_DEFAULT_FONT
|
||||||
|
* Load default raylib font on initialization to be used by DrawText() and MeasureText().
|
||||||
|
* If no default font loaded, DrawTextEx() and MeasureTextEx() are required.
|
||||||
|
*
|
||||||
|
* #define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH
|
||||||
|
* TextSplit() function static buffer max size
|
||||||
|
*
|
||||||
|
* #define TEXTSPLIT_MAX_SUBSTRINGS_COUNT
|
||||||
|
* TextSplit() function static substrings pointers array (pointing to static buffer)
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* stb_truetype - Load TTF file and rasterize characters data
|
* stb_truetype - Load TTF file and rasterize characters data
|
||||||
|
@ -63,10 +72,19 @@
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers of some Text*() functions
|
#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions:
|
||||||
|
// TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal()
|
||||||
|
|
||||||
#define MAX_TEXT_UNICODE_CHARS 512 // Maximum number of unicode codepoints
|
#define MAX_TEXT_UNICODE_CHARS 512 // Maximum number of unicode codepoints
|
||||||
|
|
||||||
|
#if !defined(TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH)
|
||||||
|
#define TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH 1024 // Size of static buffer: TextSplit()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(TEXTSPLIT_MAX_SUBSTRINGS_COUNT)
|
||||||
|
#define TEXTSPLIT_MAX_SUBSTRINGS_COUNT 128 // Size of static pointers array: TextSplit()
|
||||||
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Types and Structures Definition
|
// Types and Structures Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -1384,14 +1402,12 @@ const char **TextSplit(const char *text, char delimiter, int *count)
|
||||||
// NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter)
|
// NOTE: Current implementation returns a copy of the provided string with '\0' (string end delimiter)
|
||||||
// inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated,
|
// inserted between strings defined by "delimiter" parameter. No memory is dynamically allocated,
|
||||||
// all used memory is static... it has some limitations:
|
// all used memory is static... it has some limitations:
|
||||||
// 1. Maximum number of possible split strings is set by MAX_SUBSTRINGS_COUNT
|
// 1. Maximum number of possible split strings is set by TEXTSPLIT_MAX_SUBSTRINGS_COUNT
|
||||||
// 2. Maximum size of text to split is MAX_TEXT_BUFFER_LENGTH
|
// 2. Maximum size of text to split is TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH
|
||||||
|
|
||||||
#define MAX_SUBSTRINGS_COUNT 64
|
static const char *result[TEXTSPLIT_MAX_SUBSTRINGS_COUNT] = { NULL };
|
||||||
|
static char buffer[TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||||
static const char *result[MAX_SUBSTRINGS_COUNT] = { NULL };
|
memset(buffer, 0, TEXTSPLIT_MAX_TEXT_BUFFER_LENGTH);
|
||||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
|
||||||
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
|
||||||
|
|
||||||
result[0] = buffer;
|
result[0] = buffer;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
@ -1411,7 +1427,7 @@ const char **TextSplit(const char *text, char delimiter, int *count)
|
||||||
result[counter] = buffer + i + 1;
|
result[counter] = buffer + i + 1;
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
if (counter == MAX_SUBSTRINGS_COUNT) break;
|
if (counter == TEXTSPLIT_MAX_SUBSTRINGS_COUNT) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue