mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Compare commits
8 Commits
7729727752
...
1c3f9fa135
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c3f9fa135 | |||
| 9268b0d029 | |||
| e81fc8d21a | |||
| 23e0898c65 | |||
| 97e214fc68 | |||
| c264c86ee0 | |||
| bd6065a4fd | |||
| dc1632c17a |
2
.github/workflows/parse_api.yml
vendored
2
.github/workflows/parse_api.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
||||
- name: Diff parse files
|
||||
id: diff
|
||||
run: |
|
||||
git add -N parser
|
||||
git add -N tools/parser
|
||||
git diff --name-only --exit-code
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
@ -130,27 +130,29 @@ void ClosePlatform(void); // Close platform
|
||||
static void ErrorCallback(int error, const char *description); // GLFW3 Error Callback, runs on GLFW3 error
|
||||
|
||||
// Window callbacks events
|
||||
static void WindowSizeCallback(GLFWwindow *window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized
|
||||
static void WindowPosCallback(GLFWwindow* window, int x, int y); // GLFW3 WindowPos Callback, runs when window is moved
|
||||
static void WindowIconifyCallback(GLFWwindow *window, int iconified); // GLFW3 WindowIconify Callback, runs when window is minimized/restored
|
||||
static void WindowMaximizeCallback(GLFWwindow* window, int maximized); // GLFW3 Window Maximize Callback, runs when window is maximized
|
||||
static void WindowFocusCallback(GLFWwindow *window, int focused); // GLFW3 WindowFocus Callback, runs when window get/lose focus
|
||||
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window
|
||||
static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float scaley); // GLFW3 Window Content Scale Callback, runs when window changes scale
|
||||
static void WindowSizeCallback(GLFWwindow *window, int width, int height); // GLFW3 WindowSize Callback, runs when window is resized
|
||||
static void WindowPosCallback(GLFWwindow* window, int x, int y); // GLFW3 WindowPos Callback, runs when window is moved
|
||||
static void WindowIconifyCallback(GLFWwindow *window, int iconified); // GLFW3 WindowIconify Callback, runs when window is minimized/restored
|
||||
static void WindowMaximizeCallback(GLFWwindow* window, int maximized); // GLFW3 Window Maximize Callback, runs when window is maximized
|
||||
static void WindowFocusCallback(GLFWwindow *window, int focused); // GLFW3 WindowFocus Callback, runs when window get/lose focus
|
||||
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths); // GLFW3 Window Drop Callback, runs when drop files into window
|
||||
static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float scaley); // GLFW3 Window Content Scale Callback, runs when window changes scale
|
||||
|
||||
// Input callbacks events
|
||||
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); // GLFW3 Keyboard Callback, runs on key pressed
|
||||
static void CharCallback(GLFWwindow *window, unsigned int codepoint); // GLFW3 Char Callback, runs on key pressed (get codepoint value)
|
||||
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); // GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y); // GLFW3 Cursor Position Callback, runs on mouse move
|
||||
static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Scrolling Callback, runs on mouse wheel
|
||||
static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area
|
||||
static void JoystickCallback(int jid, int event); // GLFW3 Joystick Connected/Disconnected Callback
|
||||
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); // GLFW3 Keyboard Callback, runs on key pressed
|
||||
static void CharCallback(GLFWwindow *window, unsigned int codepoint); // GLFW3 Char Callback, runs on key pressed (get codepoint value)
|
||||
static void MouseButtonCallback(GLFWwindow *window, int button, int action, int mods); // GLFW3 Mouse Button Callback, runs on mouse button pressed
|
||||
static void MouseCursorPosCallback(GLFWwindow *window, double x, double y); // GLFW3 Cursor Position Callback, runs on mouse move
|
||||
static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffset); // GLFW3 Scrolling Callback, runs on mouse wheel
|
||||
static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area
|
||||
static void JoystickCallback(int jid, int event); // GLFW3 Joystick Connected/Disconnected Callback
|
||||
|
||||
// Wrappers used by glfwInitAllocator
|
||||
static void *AllocateWrapper(size_t size, void *user); // GLFW3 GLFWallocatefun, wrapps around RL_CALLOC macro
|
||||
static void *ReallocateWrapper(void *block, size_t size, void *user); // GLFW3 GLFWreallocatefun, wrapps around RL_REALLOC macro
|
||||
static void DeallocateWrapper(void *block, void *user); // GLFW3 GLFWdeallocatefun, wraps around RL_FREE macro
|
||||
// Memory allocator wrappers [used by glfwInitAllocator()]
|
||||
static void *AllocateWrapper(size_t size, void *user); // GLFW3 GLFWallocatefun, wrapps around RL_CALLOC macro
|
||||
static void *ReallocateWrapper(void *block, size_t size, void *user); // GLFW3 GLFWreallocatefun, wrapps around RL_REALLOC macro
|
||||
static void DeallocateWrapper(void *block, void *user); // GLFW3 GLFWdeallocatefun, wraps around RL_FREE macro
|
||||
|
||||
static void SetDimensionsFromMonitor(GLFWmonitor *monitor); // Set screen dimensions from monitor/display dimensions
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
@ -435,7 +437,7 @@ void SetWindowState(unsigned int flags)
|
||||
// State change: FLAG_INTERLACED_HINT
|
||||
if (((CORE.Window.flags & FLAG_INTERLACED_HINT) != (flags & FLAG_INTERLACED_HINT)) && ((flags & FLAG_INTERLACED_HINT) > 0))
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "RPI: Interlaced mode can only be configured before window initialization");
|
||||
TRACELOG(LOG_WARNING, "WINDOW: Interlaced mode can only be configured before window initialization");
|
||||
}
|
||||
}
|
||||
|
||||
@ -993,7 +995,7 @@ Vector2 GetWindowPosition(void)
|
||||
// Get window scale DPI factor for current monitor
|
||||
Vector2 GetWindowScaleDPI(void)
|
||||
{
|
||||
Vector2 scale = {0};
|
||||
Vector2 scale = { 0 };
|
||||
glfwGetWindowContentScale(platform.handle, &scale.x, &scale.y);
|
||||
return scale;
|
||||
}
|
||||
@ -1321,20 +1323,6 @@ void PollInputEvents(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
static void SetDimensionsFromMonitor(GLFWmonitor *monitor)
|
||||
{
|
||||
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
|
||||
|
||||
// Default display resolution to that of the current mode
|
||||
CORE.Window.display.width = mode->width;
|
||||
CORE.Window.display.height = mode->height;
|
||||
|
||||
// Set screen width/height to the display width/height if they are 0
|
||||
if (CORE.Window.screen.width == 0) CORE.Window.screen.width = CORE.Window.display.width;
|
||||
if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height;
|
||||
}
|
||||
|
||||
// Function wrappers around RL_*alloc macros, used by glfwInitAllocator() inside of InitPlatform()
|
||||
// We need to provide these because GLFWallocator expects function pointers with specific signatures
|
||||
// Similar wrappers exist in utils.c but we cannot reuse them here due to declaration mismatch
|
||||
@ -1929,8 +1917,6 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
|
||||
// GLFW3 Char Callback, get unicode codepoint value
|
||||
static void CharCallback(GLFWwindow *window, unsigned int codepoint)
|
||||
{
|
||||
//TRACELOG(LOG_DEBUG, "Char Callback: Codepoint: %i", codepoint);
|
||||
|
||||
// NOTE: Registers any key down considering OS keyboard layout but
|
||||
// does not detect action events, those should be managed by user...
|
||||
// Ref: https://github.com/glfw/glfw/issues/668#issuecomment-166794907
|
||||
@ -2041,6 +2027,20 @@ static void JoystickCallback(int jid, int event)
|
||||
}
|
||||
}
|
||||
|
||||
// Set screen dimensions from monitor/display dimensions
|
||||
static void SetDimensionsFromMonitor(GLFWmonitor *monitor)
|
||||
{
|
||||
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
|
||||
|
||||
// Default display resolution to that of the current mode
|
||||
CORE.Window.display.width = mode->width;
|
||||
CORE.Window.display.height = mode->height;
|
||||
|
||||
// Set screen width/height to the display width/height if they are 0
|
||||
if (CORE.Window.screen.width == 0) CORE.Window.screen.width = CORE.Window.display.width;
|
||||
if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_CLIPBOARD_IMPLEMENTATION
|
||||
# include "../external/win32_clipboard.h"
|
||||
|
||||
@ -240,12 +240,34 @@ static const unsigned short keyMappingRGFW[] = {
|
||||
[RGFW_scrollLock] = KEY_SCROLL_LOCK,
|
||||
};
|
||||
|
||||
static int RGFW_gpConvTable[18] = {
|
||||
[RGFW_gamepadY] = GAMEPAD_BUTTON_RIGHT_FACE_UP,
|
||||
[RGFW_gamepadB] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
|
||||
[RGFW_gamepadA] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
|
||||
[RGFW_gamepadX] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
|
||||
[RGFW_gamepadL1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1,
|
||||
[RGFW_gamepadR1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
|
||||
[RGFW_gamepadL2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2,
|
||||
[RGFW_gamepadR2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
|
||||
[RGFW_gamepadSelect] = GAMEPAD_BUTTON_MIDDLE_LEFT,
|
||||
[RGFW_gamepadHome] = GAMEPAD_BUTTON_MIDDLE,
|
||||
[RGFW_gamepadStart] = GAMEPAD_BUTTON_MIDDLE_RIGHT,
|
||||
[RGFW_gamepadUp] = GAMEPAD_BUTTON_LEFT_FACE_UP,
|
||||
[RGFW_gamepadRight] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
|
||||
[RGFW_gamepadDown] = GAMEPAD_BUTTON_LEFT_FACE_DOWN,
|
||||
[RGFW_gamepadLeft] = GAMEPAD_BUTTON_LEFT_FACE_LEFT,
|
||||
[RGFW_gamepadL3] = GAMEPAD_BUTTON_LEFT_THUMB,
|
||||
[RGFW_gamepadR3] = GAMEPAD_BUTTON_RIGHT_THUMB,
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
int InitPlatform(void); // Initialize platform (graphics, inputs and more)
|
||||
bool InitGraphicsDevice(void); // Initialize graphics device
|
||||
|
||||
static KeyboardKey ConvertScancodeToKey(u32 keycode);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -897,28 +919,6 @@ const char *GetKeyName(int key)
|
||||
return "";
|
||||
}
|
||||
|
||||
static KeyboardKey ConvertScancodeToKey(u32 keycode);
|
||||
|
||||
int RGFW_gpConvTable[18] = {
|
||||
[RGFW_gamepadY] = GAMEPAD_BUTTON_RIGHT_FACE_UP,
|
||||
[RGFW_gamepadB] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
|
||||
[RGFW_gamepadA] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
|
||||
[RGFW_gamepadX] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
|
||||
[RGFW_gamepadL1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1,
|
||||
[RGFW_gamepadR1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
|
||||
[RGFW_gamepadL2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2,
|
||||
[RGFW_gamepadR2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
|
||||
[RGFW_gamepadSelect] = GAMEPAD_BUTTON_MIDDLE_LEFT,
|
||||
[RGFW_gamepadHome] = GAMEPAD_BUTTON_MIDDLE,
|
||||
[RGFW_gamepadStart] = GAMEPAD_BUTTON_MIDDLE_RIGHT,
|
||||
[RGFW_gamepadUp] = GAMEPAD_BUTTON_LEFT_FACE_UP,
|
||||
[RGFW_gamepadRight] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
|
||||
[RGFW_gamepadDown] = GAMEPAD_BUTTON_LEFT_FACE_DOWN,
|
||||
[RGFW_gamepadLeft] = GAMEPAD_BUTTON_LEFT_FACE_LEFT,
|
||||
[RGFW_gamepadL3] = GAMEPAD_BUTTON_LEFT_THUMB,
|
||||
[RGFW_gamepadR3] = GAMEPAD_BUTTON_RIGHT_THUMB,
|
||||
};
|
||||
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
|
||||
@ -90,6 +90,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SCANCODE_MAPPED_NUM 232
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -110,10 +112,6 @@ extern CoreData CORE; // Global CORE state context
|
||||
|
||||
static PlatformData platform = { 0 }; // Platform specific data
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
#define SCANCODE_MAPPED_NUM 232
|
||||
static const KeyboardKey mapScancodeToKey[SCANCODE_MAPPED_NUM] = {
|
||||
KEY_NULL, // SDL_SCANCODE_UNKNOWN
|
||||
0,
|
||||
@ -321,7 +319,7 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||
{
|
||||
case SDL_DISABLE: SDL_SetEventEnabled(type, false); break;
|
||||
case SDL_ENABLE: SDL_SetEventEnabled(type, true); break;
|
||||
default: TRACELOG(LOG_WARNING, "Event sate: unknow type");
|
||||
default: TRACELOG(LOG_WARNING, "SDL: Event state of unknow type");
|
||||
}
|
||||
|
||||
return stateBefore;
|
||||
@ -329,10 +327,10 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||
|
||||
void SDL_GetCurrentDisplayMode_Adapter(SDL_DisplayID displayID, SDL_DisplayMode* mode)
|
||||
{
|
||||
const SDL_DisplayMode* currMode = SDL_GetCurrentDisplayMode(displayID);
|
||||
const SDL_DisplayMode *currentMode = SDL_GetCurrentDisplayMode(displayID);
|
||||
|
||||
if (currMode == NULL) TRACELOG(LOG_WARNING, "No current display mode");
|
||||
else *mode = *currMode;
|
||||
if (currentMode == NULL) TRACELOG(LOG_WARNING, "SDL: No possible to get current display mode");
|
||||
else *mode = *currentMode;
|
||||
}
|
||||
|
||||
// SDL3 Migration: Renamed
|
||||
@ -423,7 +421,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
|
||||
// SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3)
|
||||
void *SDL_GetClipboardData(const char *mime_type, size_t *size)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "Getting clipboard data that is not text is only available in SDL3");
|
||||
TRACELOG(LOG_WARNING, "SDL: Getting clipboard data that is not text not available in SDL2");
|
||||
|
||||
// We could possibly implement it ourselves in this case for some easier platforms
|
||||
return NULL;
|
||||
@ -438,8 +436,8 @@ int InitPlatform(void); // Initialize platf
|
||||
void ClosePlatform(void); // Close platform
|
||||
|
||||
static KeyboardKey ConvertScancodeToKey(SDL_Scancode sdlScancode); // Help convert SDL scancodes to raylib key
|
||||
|
||||
static int GetCodepointNextSDL(const char *text, int *codepointSize); // Get next codepoint in a byte sequence and bytes processed
|
||||
static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event); // Update CORE input touch point info from SDL touch data
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
@ -1307,41 +1305,6 @@ const char *GetKeyName(int key)
|
||||
return SDL_GetKeyName(key);
|
||||
}
|
||||
|
||||
static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event)
|
||||
{
|
||||
#if defined(USING_VERSION_SDL3) // SDL3
|
||||
int count = 0;
|
||||
SDL_Finger **fingers = SDL_GetTouchFingers(event.touchID, &count);
|
||||
CORE.Input.Touch.pointCount = count;
|
||||
|
||||
for (int i = 0; i < CORE.Input.Touch.pointCount; i++)
|
||||
{
|
||||
SDL_Finger *finger = fingers[i];
|
||||
CORE.Input.Touch.pointId[i] = finger->id;
|
||||
CORE.Input.Touch.position[i].x = finger->x*CORE.Window.screen.width;
|
||||
CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height;
|
||||
CORE.Input.Touch.currentTouchState[i] = 1;
|
||||
}
|
||||
|
||||
SDL_free(fingers);
|
||||
|
||||
#else // SDL2
|
||||
|
||||
CORE.Input.Touch.pointCount = SDL_GetNumTouchFingers(event.touchId);
|
||||
|
||||
for (int i = 0; i < CORE.Input.Touch.pointCount; i++)
|
||||
{
|
||||
SDL_Finger *finger = SDL_GetTouchFinger(event.touchId, i);
|
||||
CORE.Input.Touch.pointId[i] = finger->id;
|
||||
CORE.Input.Touch.position[i].x = finger->x*CORE.Window.screen.width;
|
||||
CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height;
|
||||
CORE.Input.Touch.currentTouchState[i] = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = CORE.Input.Touch.pointCount; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentTouchState[i] = 0;
|
||||
}
|
||||
|
||||
// Register all input events
|
||||
void PollInputEvents(void)
|
||||
{
|
||||
@ -1399,15 +1362,9 @@ void PollInputEvents(void)
|
||||
|
||||
// Poll input events for current platform
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
// WARNING: Indexes into this array are obtained by using SDL_Scancode values, not SDL_Keycode values
|
||||
const Uint8 *keys = SDL_GetKeyboardState(NULL);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
CORE.Input.Keyboard.currentKeyState[i] = keys[i];
|
||||
//if (keys[i]) TRACELOG(LOG_WARNING, "Pressed key: %i", i);
|
||||
}
|
||||
*/
|
||||
//const Uint8 *keys = SDL_GetKeyboardState(NULL);
|
||||
//for (int i = 0; i < 256; ++i) CORE.Input.Keyboard.currentKeyState[i] = keys[i];
|
||||
|
||||
CORE.Window.resizedLastFrame = false;
|
||||
|
||||
@ -2174,3 +2131,39 @@ static int GetCodepointNextSDL(const char *text, int *codepointSize)
|
||||
|
||||
return codepoint;
|
||||
}
|
||||
|
||||
// Update CORE input touch point info from SDL touch data
|
||||
static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event)
|
||||
{
|
||||
#if defined(USING_VERSION_SDL3) // SDL3
|
||||
int count = 0;
|
||||
SDL_Finger **fingers = SDL_GetTouchFingers(event.touchID, &count);
|
||||
CORE.Input.Touch.pointCount = count;
|
||||
|
||||
for (int i = 0; i < CORE.Input.Touch.pointCount; i++)
|
||||
{
|
||||
SDL_Finger *finger = fingers[i];
|
||||
CORE.Input.Touch.pointId[i] = finger->id;
|
||||
CORE.Input.Touch.position[i].x = finger->x*CORE.Window.screen.width;
|
||||
CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height;
|
||||
CORE.Input.Touch.currentTouchState[i] = 1;
|
||||
}
|
||||
|
||||
SDL_free(fingers);
|
||||
|
||||
#else // SDL2
|
||||
|
||||
CORE.Input.Touch.pointCount = SDL_GetNumTouchFingers(event.touchId);
|
||||
|
||||
for (int i = 0; i < CORE.Input.Touch.pointCount; i++)
|
||||
{
|
||||
SDL_Finger *finger = SDL_GetTouchFinger(event.touchId, i);
|
||||
CORE.Input.Touch.pointId[i] = finger->id;
|
||||
CORE.Input.Touch.position[i].x = finger->x*CORE.Window.screen.width;
|
||||
CORE.Input.Touch.position[i].y = finger->y*CORE.Window.screen.height;
|
||||
CORE.Input.Touch.currentTouchState[i] = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = CORE.Input.Touch.pointCount; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.currentTouchState[i] = 0;
|
||||
}
|
||||
|
||||
@ -245,6 +245,7 @@ static void RestoreKeyboard(void); // Restore keyboard system
|
||||
static void ProcessKeyboard(void); // Process keyboard events
|
||||
#endif
|
||||
|
||||
// Input management functions
|
||||
static void InitEvdevInput(void); // Initialize evdev inputs
|
||||
static void ConfigureEvdevDevice(char *device); // Identifies a input device and configures it for use if appropriate
|
||||
static void PollKeyboardEvents(void); // Process evdev keyboard events
|
||||
@ -703,7 +704,7 @@ void SwapScreenBuffer()
|
||||
if (!crtcSet || !platform.gbmSurface) return;
|
||||
|
||||
static int loopCnt = 0;
|
||||
static int errCnt[5] = {0};
|
||||
static int errCnt[5] = { 0 };
|
||||
loopCnt++;
|
||||
|
||||
// Call this only, if pendingFlip is not set
|
||||
|
||||
@ -1722,8 +1722,7 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
GestureEvent gestureEvent = {0};
|
||||
|
||||
GestureEvent gestureEvent = { 0 };
|
||||
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
|
||||
|
||||
// Register touch actions
|
||||
@ -1852,7 +1851,7 @@ static EM_BOOL EmscriptenVisibilityChangeCallback(int eventType, const Emscripte
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
// JS: Get the canvas id provided by the module configuration
|
||||
EM_JS(char*, GetCanvasIdJs, (), {
|
||||
EM_JS(char *, GetCanvasIdJs, (), {
|
||||
var canvasId = "#" + Module.canvas.id;
|
||||
var lengthBytes = lengthBytesUTF8(canvasId) + 1;
|
||||
var stringOnWasmHeap = _malloc(lengthBytes);
|
||||
|
||||
77
src/raylib.h
77
src/raylib.h
@ -1110,45 +1110,51 @@ RLAPI void MemFree(void *ptr); // Internal me
|
||||
|
||||
// Set custom callbacks
|
||||
// WARNING: Callbacks setup is intended for advanced users
|
||||
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
|
||||
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
|
||||
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
|
||||
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader
|
||||
RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver
|
||||
RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log
|
||||
RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader
|
||||
RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver
|
||||
RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader
|
||||
RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver
|
||||
|
||||
// Files management functions
|
||||
RLAPI unsigned char *LoadFileData(const char *fileName, int *dataSize); // Load file data as byte array (read)
|
||||
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
|
||||
RLAPI void UnloadFileData(unsigned char *data); // Unload file data allocated by LoadFileData()
|
||||
RLAPI bool SaveFileData(const char *fileName, void *data, int dataSize); // Save data to file from byte array (write), returns true on success
|
||||
RLAPI bool ExportDataAsCode(const unsigned char *data, int dataSize, const char *fileName); // Export data to code (.h), returns true on success
|
||||
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
|
||||
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
|
||||
RLAPI bool SaveFileText(const char *fileName, const char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
|
||||
RLAPI char *LoadFileText(const char *fileName); // Load text data from file (read), returns a '\0' terminated string
|
||||
RLAPI void UnloadFileText(char *text); // Unload file text data allocated by LoadFileText()
|
||||
RLAPI bool SaveFileText(const char *fileName, const char *text); // Save text data to file (write), string must be '\0' terminated, returns true on success
|
||||
//------------------------------------------------------------------
|
||||
|
||||
// File system functions
|
||||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (recommended include point: .png, .wav)
|
||||
RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
|
||||
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')
|
||||
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
|
||||
RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string)
|
||||
RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string)
|
||||
RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string)
|
||||
RLAPI const char *GetApplicationDirectory(void); // Get the directory of the running application (uses static string)
|
||||
RLAPI int MakeDirectory(const char *dirPath); // Create directories (including full path requested), returns 0 on success
|
||||
RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success
|
||||
RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory
|
||||
RLAPI bool IsFileNameValid(const char *fileName); // Check if fileName is valid for the platform/OS
|
||||
RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths
|
||||
RLAPI int FileRename(const char *fileName, const char *fileRename); // Rename file (if exists)
|
||||
RLAPI int FileRemove(const char *fileName); // Remove file (if exists)
|
||||
RLAPI int FileCopy(const char *srcPath, const char *dstPath); // Copy file from one path to another, dstPath created if it doesn't exist
|
||||
RLAPI int FileMove(const char *srcPath, const char *dstPath); // Move file from one directory to another, dstPath created if it doesn't exist
|
||||
RLAPI int FileTextReplace(const char *fileName, const char *search, const char *replacement); // Replace text in an existing file
|
||||
RLAPI int FileTextFindIndex(const char *fileName, const char *search); // Find text in existing file
|
||||
RLAPI bool FileExists(const char *fileName); // Check if file exists
|
||||
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
|
||||
RLAPI bool IsFileExtension(const char *fileName, const char *ext); // Check file extension (recommended include point: .png, .wav)
|
||||
RLAPI int GetFileLength(const char *fileName); // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)
|
||||
RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)
|
||||
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: '.png')
|
||||
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
|
||||
RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string)
|
||||
RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string)
|
||||
RLAPI const char *GetPrevDirectoryPath(const char *dirPath); // Get previous directory path for a given path (uses static string)
|
||||
RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string)
|
||||
RLAPI const char *GetApplicationDirectory(void); // Get the directory of the running application (uses static string)
|
||||
RLAPI int MakeDirectory(const char *dirPath); // Create directories (including full path requested), returns 0 on success
|
||||
RLAPI bool ChangeDirectory(const char *dir); // Change working directory, return true on success
|
||||
RLAPI bool IsPathFile(const char *path); // Check if a given path is a file or a directory
|
||||
RLAPI bool IsFileNameValid(const char *fileName); // Check if fileName is valid for the platform/OS
|
||||
RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths
|
||||
RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and recursive directory scan. Use 'DIR' in the filter string to include directories in the result
|
||||
RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths
|
||||
RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window
|
||||
RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths
|
||||
RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths
|
||||
RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)
|
||||
RLAPI void UnloadDirectoryFiles(FilePathList files); // Unload filepaths
|
||||
RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window
|
||||
RLAPI FilePathList LoadDroppedFiles(void); // Load dropped filepaths
|
||||
RLAPI void UnloadDroppedFiles(FilePathList files); // Unload dropped filepaths
|
||||
|
||||
// Compression/Encoding functionality
|
||||
RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); // Compress data (DEFLATE algorithm), memory must be MemFree()
|
||||
@ -1504,7 +1510,7 @@ RLAPI int GetCodepointPrevious(const char *text, int *codepointSize);
|
||||
RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)
|
||||
|
||||
// Text strings management functions (no UTF-8 strings, only byte chars)
|
||||
// WARNING 1: Most of these functions use internal static buffers, it's recommended to store returned data on user-side for re-use
|
||||
// WARNING 1: Most of these functions use internal static buffers[], it's recommended to store returned data on user-side for re-use
|
||||
// WARNING 2: Some strings allocate memory internally for the returned strings, those strings must be free by user using MemFree()
|
||||
RLAPI char **LoadTextLines(const char *text, int *count); // Load text as separate lines ('\n')
|
||||
RLAPI void UnloadTextLines(char **text, int lineCount); // Unload text lines
|
||||
@ -1513,12 +1519,15 @@ RLAPI bool TextIsEqual(const char *text1, const char *text2);
|
||||
RLAPI unsigned int TextLength(const char *text); // Get text length, checks for '\0' ending
|
||||
RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf() style)
|
||||
RLAPI const char *TextSubtext(const char *text, int position, int length); // Get a piece of a text string
|
||||
RLAPI char *TextReplace(const char *text, const char *replace, const char *by); // Replace text string (WARNING: memory must be freed!)
|
||||
RLAPI const char *TextRemoveSpaces(const char *text); // Remove text spaces, concat words
|
||||
RLAPI char *GetTextBetween(const char *text, const char *begin, const char *end); // Get text between two strings
|
||||
RLAPI char *TextReplace(const char *text, const char *search, const char *replacement); // Replace text string (WARNING: memory must be freed!)
|
||||
RLAPI char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings (WARNING: memory must be freed!)
|
||||
RLAPI char *TextInsert(const char *text, const char *insert, int position); // Insert text in a position (WARNING: memory must be freed!)
|
||||
RLAPI char *TextJoin(char **textList, int count, const char *delimiter); // Join text strings with delimiter
|
||||
RLAPI char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings, using MAX_TEXTSPLIT_COUNT static strings
|
||||
RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor!
|
||||
RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string, -1 if not found
|
||||
RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor
|
||||
RLAPI int TextFindIndex(const char *text, const char *search); // Find first text occurrence within a string, -1 if not found
|
||||
RLAPI char *TextToUpper(const char *text); // Get upper case version of provided string
|
||||
RLAPI char *TextToLower(const char *text); // Get lower case version of provided string
|
||||
RLAPI char *TextToPascal(const char *text); // Get Pascal case notation version of provided string
|
||||
|
||||
149
src/rcore.c
149
src/rcore.c
@ -1927,6 +1927,115 @@ void SetConfigFlags(unsigned int flags)
|
||||
// Module Functions Definition: File system
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Rename file (if exists)
|
||||
// NOTE: Only rename file name required, not full path
|
||||
int FileRename(const char *fileName, const char *fileRename)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (FileExists(fileName))
|
||||
{
|
||||
result = rename(fileName, fileRename);
|
||||
}
|
||||
else result = -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Remove file (if exists)
|
||||
int FileRemove(const char *fileName)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (FileExists(fileName))
|
||||
{
|
||||
result = remove(fileName);
|
||||
}
|
||||
else result = -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Copy file from one path to another
|
||||
// NOTE: If destination path does not exist, it is created!
|
||||
int FileCopy(const char *srcPath, const char *dstPath)
|
||||
{
|
||||
int result = 0;
|
||||
int srcDataSize = 0;
|
||||
unsigned char *srcFileData = LoadFileData(srcPath, &srcDataSize);
|
||||
|
||||
// Create required paths if they do not exist
|
||||
if (!DirectoryExists(GetDirectoryPath(dstPath)))
|
||||
result = MakeDirectory(GetDirectoryPath(dstPath));
|
||||
|
||||
if (result == 0) // Directory created successfully (or already exists)
|
||||
{
|
||||
if ((srcFileData != NULL) && (srcDataSize > 0))
|
||||
result = SaveFileData(dstPath, srcFileData, srcDataSize);
|
||||
}
|
||||
|
||||
UnloadFileData(srcFileData);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Move file from one directory to another
|
||||
// NOTE: If dst directories do not exists they are created
|
||||
int FileMove(const char *srcPath, const char *dstPath)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (FileExists(srcPath))
|
||||
{
|
||||
FileCopy(srcPath, dstPath);
|
||||
FileRemove(srcPath);
|
||||
}
|
||||
else result = -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Replace text in an existing file
|
||||
// WARNING: DEPENDENCY: [rtext] module
|
||||
int FileTextReplace(const char *fileName, const char *search, const char *replacement)
|
||||
{
|
||||
int result = 0;
|
||||
char *fileText = NULL;
|
||||
char *fileTextUpdated = { 0 };
|
||||
|
||||
#if defined(SUPPORT_MODULE_RTEXT)
|
||||
if (FileExists(fileName))
|
||||
{
|
||||
fileText = LoadFileText(fileName);
|
||||
fileTextUpdated = TextReplace(fileText, search, replacement);
|
||||
result = SaveFileText(fileName, fileTextUpdated);
|
||||
MemFree(fileTextUpdated);
|
||||
UnloadFileText(fileText);
|
||||
}
|
||||
#else
|
||||
TRACELOG(LOG_WARNING, "FILE: File text replace requires [rtext] module");
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find text index position in existing file
|
||||
// WARNING: DEPENDENCY: [rtext] module
|
||||
int FileTextFindIndex(const char *fileName, const char *search)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
if (FileExists(fileName))
|
||||
{
|
||||
char *fileText = LoadFileText(fileName);
|
||||
char *ptr = strstr(fileText, search);
|
||||
if (ptr != NULL) result = (int)(ptr - fileText);
|
||||
UnloadFileText(fileText);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check if the file exists
|
||||
bool FileExists(const char *fileName)
|
||||
{
|
||||
@ -2054,6 +2163,21 @@ int GetFileLength(const char *fileName)
|
||||
return size;
|
||||
}
|
||||
|
||||
// Get file modification time (last write time)
|
||||
long GetFileModTime(const char *fileName)
|
||||
{
|
||||
struct stat result = { 0 };
|
||||
long modTime = 0;
|
||||
|
||||
if (stat(fileName, &result) == 0)
|
||||
{
|
||||
time_t mod = result.st_mtime;
|
||||
modTime = (long)mod;
|
||||
}
|
||||
|
||||
return modTime;
|
||||
}
|
||||
|
||||
// Get pointer to extension for a filename string (includes the dot: .png)
|
||||
// WARNING: We just get the ptr but not the extension as a separate string
|
||||
const char *GetFileExtension(const char *fileName)
|
||||
@ -2367,7 +2491,7 @@ void UnloadDirectoryFiles(FilePathList files)
|
||||
// Create directories (including full path requested), returns 0 on success
|
||||
int MakeDirectory(const char *dirPath)
|
||||
{
|
||||
if ((dirPath == NULL) || (dirPath[0] == '\0')) return 1; // Path is not valid
|
||||
if ((dirPath == NULL) || (dirPath[0] == '\0')) return -1; // Path is not valid
|
||||
if (DirectoryExists(dirPath)) return 0; // Path already exists (is valid)
|
||||
|
||||
// Copy path string to avoid modifying original
|
||||
@ -2392,8 +2516,11 @@ int MakeDirectory(const char *dirPath)
|
||||
|
||||
// Create final directory
|
||||
if (!DirectoryExists(pathcpy)) MKDIR(pathcpy);
|
||||
|
||||
RL_FREE(pathcpy);
|
||||
|
||||
// In case something failed and requested directory
|
||||
// was not successfully created, return -1
|
||||
if (!DirectoryExists(dirPath)) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2513,22 +2640,6 @@ void UnloadDroppedFiles(FilePathList files)
|
||||
}
|
||||
}
|
||||
|
||||
// Get file modification time (last write time)
|
||||
long GetFileModTime(const char *fileName)
|
||||
{
|
||||
struct stat result = { 0 };
|
||||
long modTime = 0;
|
||||
|
||||
if (stat(fileName, &result) == 0)
|
||||
{
|
||||
time_t mod = result.st_mtime;
|
||||
|
||||
modTime = (long)mod;
|
||||
}
|
||||
|
||||
return modTime;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition: Compression and Encoding
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -2903,7 +3014,7 @@ unsigned int *ComputeSHA1(unsigned char *data, int dataSize)
|
||||
for (int offset = 0; offset < newDataSize; offset += (512/8))
|
||||
{
|
||||
// Break chunk into sixteen 32-bit words w[j], 0 <= j <= 15
|
||||
unsigned int w[80] = {0};
|
||||
unsigned int w[80] = { 0 };
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
w[i] = (msg[offset + (i*4) + 0] << 24) |
|
||||
|
||||
@ -2474,7 +2474,7 @@ void rlLoadExtensions(void *loader)
|
||||
}
|
||||
|
||||
// Check instanced rendering support
|
||||
if (strstr(extList[i], (const char*)"instanced_arrays") != NULL) // Broad check for instanced_arrays
|
||||
if (strstr(extList[i], (const char *)"instanced_arrays") != NULL) // Broad check for instanced_arrays
|
||||
{
|
||||
// Specific check
|
||||
if (strcmp(extList[i], (const char *)"GL_ANGLE_instanced_arrays") == 0) // ANGLE
|
||||
@ -2507,7 +2507,7 @@ void rlLoadExtensions(void *loader)
|
||||
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedEXT");
|
||||
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedEXT");
|
||||
}
|
||||
else if (strcmp(extList[i], (const char*)"GL_NV_draw_instanced") == 0)
|
||||
else if (strcmp(extList[i], (const char *)"GL_NV_draw_instanced") == 0)
|
||||
{
|
||||
glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawArraysInstancedNV");
|
||||
glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)((rlglLoadProc)loader)("glDrawElementsInstancedNV");
|
||||
|
||||
130
src/rtext.c
130
src/rtext.c
@ -1649,34 +1649,79 @@ const char *TextSubtext(const char *text, int position, int length)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// Remove text spaces, concat words
|
||||
const char *TextRemoveSpaces(const char *text)
|
||||
{
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
||||
|
||||
if (text != NULL)
|
||||
{
|
||||
// Avoid copying the ' ' characters
|
||||
for (int i = 0, j = 0; (i < MAX_TEXT_BUFFER_LENGTH - 1) && (text[j] != '\0'); i++)
|
||||
{
|
||||
if (text[i] != ' ') { buffer[j] = text[i]; j++; }
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// Get text between two strings
|
||||
char *GetTextBetween(const char *text, const char *begin, const char *end)
|
||||
{
|
||||
#define MAX_TEXT_BETWEEN_SIZE 1024
|
||||
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
||||
|
||||
int beginIndex = TextFindIndex(text, begin);
|
||||
|
||||
if (beginIndex > -1)
|
||||
{
|
||||
int beginLen = strlen(begin);
|
||||
int endIndex = TextFindIndex(text + beginIndex + beginLen, end);
|
||||
|
||||
if (endIndex > -1)
|
||||
{
|
||||
endIndex += (beginIndex + beginLen);
|
||||
int len = (endIndex - beginIndex - beginLen);
|
||||
if (len < (MAX_TEXT_BETWEEN_SIZE - 1)) strncpy(buffer, text + beginIndex + beginLen, len);
|
||||
else strncpy(buffer, text + beginIndex + beginLen, MAX_TEXT_BETWEEN_SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// Replace text string
|
||||
// REQUIRES: strstr(), strncpy(), strcpy()
|
||||
// TODO: If (replacement == NULL) remove "search" text
|
||||
// WARNING: Allocated memory must be manually freed
|
||||
char *TextReplace(const char *text, const char *replace, const char *by)
|
||||
char *TextReplace(const char *text, const char *search, const char *replacement)
|
||||
{
|
||||
// Sanity checks and initialization
|
||||
if (!text || !replace || !by) return NULL;
|
||||
|
||||
char *result = NULL;
|
||||
|
||||
|
||||
if (!text || !search) return NULL; // Sanity check
|
||||
|
||||
char *insertPoint = NULL; // Next insert point
|
||||
char *temp = NULL; // Temp pointer
|
||||
int replaceLen = 0; // Replace string length of (the string to remove)
|
||||
int byLen = 0; // Replacement length (the string to replace by)
|
||||
int lastReplacePos = 0; // Distance between replace and end of last replace
|
||||
int searchLen = 0; // Search string length of (the string to remove)
|
||||
int replaceLen = 0; // Replacement length (the string to replace by)
|
||||
int lastReplacePos = 0; // Distance between next search and end of last replace
|
||||
int count = 0; // Number of replacements
|
||||
|
||||
replaceLen = TextLength(replace);
|
||||
if (replaceLen == 0) return NULL; // Empty replace causes infinite loop during count
|
||||
searchLen = TextLength(search);
|
||||
if (searchLen == 0) return NULL; // Empty search causes infinite loop during count
|
||||
|
||||
byLen = TextLength(by);
|
||||
replaceLen = TextLength(replacement);
|
||||
|
||||
// Count the number of replacements needed
|
||||
insertPoint = (char *)text;
|
||||
for (count = 0; (temp = strstr(insertPoint, replace)); count++) insertPoint = temp + replaceLen;
|
||||
for (count = 0; (temp = strstr(insertPoint, search)); count++) insertPoint = temp + searchLen;
|
||||
|
||||
// Allocate returning string and point temp to it
|
||||
temp = result = (char *)RL_MALLOC(TextLength(text) + (byLen - replaceLen)*count + 1);
|
||||
temp = result = (char *)RL_MALLOC(TextLength(text) + (replaceLen - searchLen)*count + 1);
|
||||
|
||||
if (!result) return NULL; // Memory could not be allocated
|
||||
|
||||
@ -1686,11 +1731,11 @@ char *TextReplace(const char *text, const char *replace, const char *by)
|
||||
// - 'text' points to the remainder of text after "end of replace"
|
||||
while (count--)
|
||||
{
|
||||
insertPoint = strstr(text, replace);
|
||||
insertPoint = strstr(text, search);
|
||||
lastReplacePos = (int)(insertPoint - text);
|
||||
temp = strncpy(temp, text, lastReplacePos) + lastReplacePos;
|
||||
temp = strcpy(temp, by) + byLen;
|
||||
text += lastReplacePos + replaceLen; // Move to next "end of replace"
|
||||
temp = strcpy(temp, replacement) + replaceLen;
|
||||
text += lastReplacePos + searchLen; // Move to next "end of replace"
|
||||
}
|
||||
|
||||
// Copy remaind text part after replacement to result (pointed by moving temp)
|
||||
@ -1699,6 +1744,41 @@ char *TextReplace(const char *text, const char *replace, const char *by)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Replace text between two specific strings
|
||||
// REQUIRES: strlen(), strncpy()
|
||||
// NOTE: If (replacement == NULL) remove "begin"[ ]"end" text
|
||||
// WARNING: Returned string must be freed by user
|
||||
char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement)
|
||||
{
|
||||
char *result = NULL;
|
||||
|
||||
if (!text || !begin || !end) return NULL; // Sanity check
|
||||
|
||||
int beginIndex = TextFindIndex(text, begin);
|
||||
|
||||
if (beginIndex > -1)
|
||||
{
|
||||
int beginLen = strlen(begin);
|
||||
int endIndex = TextFindIndex(text + beginIndex + beginLen, end);
|
||||
|
||||
if (endIndex > -1)
|
||||
{
|
||||
endIndex += (beginIndex + beginLen);
|
||||
|
||||
int textLen = strlen(text);
|
||||
int replaceLen = (replacement == NULL)? 0 : strlen(replacement);
|
||||
int toreplaceLen = endIndex - beginIndex - beginLen;
|
||||
result = (char *)RL_CALLOC(textLen + replaceLen - toreplaceLen + 1, sizeof(char));
|
||||
|
||||
strncpy(result, text, beginIndex + beginLen); // Copy first text part
|
||||
if (replacement != NULL) strncpy(result + beginIndex + beginLen, replacement, replaceLen); // Copy replacement (if provided)
|
||||
strncpy(result + beginIndex + beginLen + replaceLen, text + endIndex, textLen - endIndex); // Copy end text part
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Insert text in a specific position, moves all text forward
|
||||
// WARNING: Allocated memory must be manually freed
|
||||
char *TextInsert(const char *text, const char *insert, int position)
|
||||
@ -1761,11 +1841,11 @@ char **TextSplit(const char *text, char delimiter, int *count)
|
||||
// 1. Maximum number of possible split strings is set by MAX_TEXTSPLIT_COUNT
|
||||
// 2. Maximum size of text to split is MAX_TEXT_BUFFER_LENGTH
|
||||
|
||||
static char *result[MAX_TEXTSPLIT_COUNT] = { NULL };
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||
static char *buffers[MAX_TEXTSPLIT_COUNT] = { NULL }; // Pointers to buffer[] text data
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; // Text data with '\0' separators
|
||||
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
||||
|
||||
result[0] = buffer;
|
||||
buffers[0] = buffer;
|
||||
int counter = 0;
|
||||
|
||||
if (text != NULL)
|
||||
@ -1780,7 +1860,7 @@ char **TextSplit(const char *text, char delimiter, int *count)
|
||||
else if (buffer[i] == delimiter)
|
||||
{
|
||||
buffer[i] = '\0'; // Set an end of string at this point
|
||||
result[counter] = buffer + i + 1;
|
||||
buffers[counter] = buffer + i + 1;
|
||||
counter++;
|
||||
|
||||
if (counter == MAX_TEXTSPLIT_COUNT) break;
|
||||
@ -1789,7 +1869,7 @@ char **TextSplit(const char *text, char delimiter, int *count)
|
||||
}
|
||||
|
||||
*count = counter;
|
||||
return result;
|
||||
return buffers;
|
||||
}
|
||||
|
||||
// Append text at specific position and move cursor
|
||||
@ -1803,11 +1883,11 @@ void TextAppend(char *text, const char *append, int *position)
|
||||
|
||||
// Find first text occurrence within a string
|
||||
// REQUIRES: strstr()
|
||||
int TextFindIndex(const char *text, const char *find)
|
||||
int TextFindIndex(const char *text, const char *search)
|
||||
{
|
||||
int position = -1;
|
||||
|
||||
char *ptr = strstr(text, find);
|
||||
char *ptr = strstr(text, search);
|
||||
|
||||
if (ptr != NULL) position = (int)(ptr - text);
|
||||
|
||||
@ -1885,7 +1965,7 @@ char *TextToPascal(const char *text)
|
||||
// WARNING: Limited functionality, only basic characters set
|
||||
char *TextToSnake(const char *text)
|
||||
{
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = {0};
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
||||
|
||||
if (text != NULL)
|
||||
@ -1913,7 +1993,7 @@ char *TextToSnake(const char *text)
|
||||
// WARNING: Limited functionality, only basic characters set
|
||||
char *TextToCamel(const char *text)
|
||||
{
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = {0};
|
||||
static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 };
|
||||
memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH);
|
||||
|
||||
if (text != NULL)
|
||||
|
||||
@ -4414,6 +4414,96 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FileRename",
|
||||
"description": "Rename file (if exists)",
|
||||
"returnType": "int",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileName"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileRename"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FileRemove",
|
||||
"description": "Remove file (if exists)",
|
||||
"returnType": "int",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileName"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FileCopy",
|
||||
"description": "Copy file from one path to another, dstPath created if it doesn't exist",
|
||||
"returnType": "int",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "srcPath"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "dstPath"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FileMove",
|
||||
"description": "Move file from one directory to another, dstPath created if it doesn't exist",
|
||||
"returnType": "int",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "srcPath"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "dstPath"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FileTextReplace",
|
||||
"description": "Replace text in an existing file",
|
||||
"returnType": "int",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileName"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "search"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "replacement"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FileTextFindIndex",
|
||||
"description": "Find text in existing file",
|
||||
"returnType": "int",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileName"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "search"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "FileExists",
|
||||
"description": "Check if file exists",
|
||||
@ -4462,6 +4552,17 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "GetFileModTime",
|
||||
"description": "Get file modification time (last write time)",
|
||||
"returnType": "long",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileName"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "GetFileExtension",
|
||||
"description": "Get pointer to extension for a filename string (includes dot: '.png')",
|
||||
@ -4633,17 +4734,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "GetFileModTime",
|
||||
"description": "Get file modification time (last write time)",
|
||||
"returnType": "long",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "fileName"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CompressData",
|
||||
"description": "Compress data (DEFLATE algorithm), memory must be MemFree()",
|
||||
@ -9714,6 +9804,36 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TextRemoveSpaces",
|
||||
"description": "Remove text spaces, concat words",
|
||||
"returnType": "const char *",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "GetTextBetween",
|
||||
"description": "Get text between two strings",
|
||||
"returnType": "char *",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "text"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "begin"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "end"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TextReplace",
|
||||
"description": "Replace text string (WARNING: memory must be freed!)",
|
||||
@ -9725,11 +9845,34 @@
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "replace"
|
||||
"name": "search"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "by"
|
||||
"name": "replacement"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TextReplaceBetween",
|
||||
"description": "Replace text between two specific strings (WARNING: memory must be freed!)",
|
||||
"returnType": "char *",
|
||||
"params": [
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "text"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "begin"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "end"
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "replacement"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -9792,7 +9935,7 @@
|
||||
},
|
||||
{
|
||||
"name": "TextAppend",
|
||||
"description": "Append text at specific position and move cursor!",
|
||||
"description": "Append text at specific position and move cursor",
|
||||
"returnType": "void",
|
||||
"params": [
|
||||
{
|
||||
@ -9820,7 +9963,7 @@
|
||||
},
|
||||
{
|
||||
"type": "const char *",
|
||||
"name": "find"
|
||||
"name": "search"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -4009,6 +4009,60 @@ return {
|
||||
{type = "const char *", name = "text"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "FileRename",
|
||||
description = "Rename file (if exists)",
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "const char *", name = "fileName"},
|
||||
{type = "const char *", name = "fileRename"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "FileRemove",
|
||||
description = "Remove file (if exists)",
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "const char *", name = "fileName"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "FileCopy",
|
||||
description = "Copy file from one path to another, dstPath created if it doesn't exist",
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "const char *", name = "srcPath"},
|
||||
{type = "const char *", name = "dstPath"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "FileMove",
|
||||
description = "Move file from one directory to another, dstPath created if it doesn't exist",
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "const char *", name = "srcPath"},
|
||||
{type = "const char *", name = "dstPath"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "FileTextReplace",
|
||||
description = "Replace text in an existing file",
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "const char *", name = "fileName"},
|
||||
{type = "const char *", name = "search"},
|
||||
{type = "const char *", name = "replacement"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "FileTextFindIndex",
|
||||
description = "Find text in existing file",
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "const char *", name = "fileName"},
|
||||
{type = "const char *", name = "search"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "FileExists",
|
||||
description = "Check if file exists",
|
||||
@ -4042,6 +4096,14 @@ return {
|
||||
{type = "const char *", name = "fileName"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "GetFileModTime",
|
||||
description = "Get file modification time (last write time)",
|
||||
returnType = "long",
|
||||
params = {
|
||||
{type = "const char *", name = "fileName"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "GetFileExtension",
|
||||
description = "Get pointer to extension for a filename string (includes dot: '.png')",
|
||||
@ -4168,14 +4230,6 @@ return {
|
||||
{type = "FilePathList", name = "files"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "GetFileModTime",
|
||||
description = "Get file modification time (last write time)",
|
||||
returnType = "long",
|
||||
params = {
|
||||
{type = "const char *", name = "fileName"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "CompressData",
|
||||
description = "Compress data (DEFLATE algorithm), memory must be MemFree()",
|
||||
@ -6909,14 +6963,43 @@ return {
|
||||
{type = "int", name = "length"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "TextRemoveSpaces",
|
||||
description = "Remove text spaces, concat words",
|
||||
returnType = "const char *",
|
||||
params = {
|
||||
{type = "const char *", name = "text"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "GetTextBetween",
|
||||
description = "Get text between two strings",
|
||||
returnType = "char *",
|
||||
params = {
|
||||
{type = "const char *", name = "text"},
|
||||
{type = "const char *", name = "begin"},
|
||||
{type = "const char *", name = "end"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "TextReplace",
|
||||
description = "Replace text string (WARNING: memory must be freed!)",
|
||||
returnType = "char *",
|
||||
params = {
|
||||
{type = "const char *", name = "text"},
|
||||
{type = "const char *", name = "replace"},
|
||||
{type = "const char *", name = "by"}
|
||||
{type = "const char *", name = "search"},
|
||||
{type = "const char *", name = "replacement"}
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "TextReplaceBetween",
|
||||
description = "Replace text between two specific strings (WARNING: memory must be freed!)",
|
||||
returnType = "char *",
|
||||
params = {
|
||||
{type = "const char *", name = "text"},
|
||||
{type = "const char *", name = "begin"},
|
||||
{type = "const char *", name = "end"},
|
||||
{type = "const char *", name = "replacement"}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -6951,7 +7034,7 @@ return {
|
||||
},
|
||||
{
|
||||
name = "TextAppend",
|
||||
description = "Append text at specific position and move cursor!",
|
||||
description = "Append text at specific position and move cursor",
|
||||
returnType = "void",
|
||||
params = {
|
||||
{type = "char *", name = "text"},
|
||||
@ -6965,7 +7048,7 @@ return {
|
||||
returnType = "int",
|
||||
params = {
|
||||
{type = "const char *", name = "text"},
|
||||
{type = "const char *", name = "find"}
|
||||
{type = "const char *", name = "search"}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -679,7 +679,7 @@
|
||||
<Param type="unsigned int" name="frames" desc="" />
|
||||
</Callback>
|
||||
</Callbacks>
|
||||
<Functions count="586">
|
||||
<Functions count="595">
|
||||
<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="" />
|
||||
@ -1048,6 +1048,30 @@
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
</Function>
|
||||
<Function name="FileRename" retType="int" paramCount="2" desc="Rename file (if exists)">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
<Param type="const char *" name="fileRename" desc="" />
|
||||
</Function>
|
||||
<Function name="FileRemove" retType="int" paramCount="1" desc="Remove file (if exists)">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
<Function name="FileCopy" retType="int" paramCount="2" desc="Copy file from one path to another, dstPath created if it doesn't exist">
|
||||
<Param type="const char *" name="srcPath" desc="" />
|
||||
<Param type="const char *" name="dstPath" desc="" />
|
||||
</Function>
|
||||
<Function name="FileMove" retType="int" paramCount="2" desc="Move file from one directory to another, dstPath created if it doesn't exist">
|
||||
<Param type="const char *" name="srcPath" desc="" />
|
||||
<Param type="const char *" name="dstPath" desc="" />
|
||||
</Function>
|
||||
<Function name="FileTextReplace" retType="int" paramCount="3" desc="Replace text in an existing file">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
<Param type="const char *" name="search" desc="" />
|
||||
<Param type="const char *" name="replacement" desc="" />
|
||||
</Function>
|
||||
<Function name="FileTextFindIndex" retType="int" paramCount="2" desc="Find text in existing file">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
<Param type="const char *" name="search" desc="" />
|
||||
</Function>
|
||||
<Function name="FileExists" retType="bool" paramCount="1" desc="Check if file exists">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
@ -1061,6 +1085,9 @@
|
||||
<Function name="GetFileLength" retType="int" paramCount="1" desc="Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h)">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
<Function name="GetFileModTime" retType="long" paramCount="1" desc="Get file modification time (last write time)">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
<Function name="GetFileExtension" retType="const char *" paramCount="1" desc="Get pointer to extension for a filename string (includes dot: '.png')">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
@ -1110,9 +1137,6 @@
|
||||
<Function name="UnloadDroppedFiles" retType="void" paramCount="1" desc="Unload dropped filepaths">
|
||||
<Param type="FilePathList" name="files" desc="" />
|
||||
</Function>
|
||||
<Function name="GetFileModTime" retType="long" paramCount="1" desc="Get file modification time (last write time)">
|
||||
<Param type="const char *" name="fileName" desc="" />
|
||||
</Function>
|
||||
<Function name="CompressData" retType="unsigned char *" paramCount="3" desc="Compress data (DEFLATE algorithm), memory must be MemFree()">
|
||||
<Param type="const unsigned char *" name="data" desc="" />
|
||||
<Param type="int" name="dataSize" desc="" />
|
||||
@ -2464,10 +2488,24 @@
|
||||
<Param type="int" name="position" desc="" />
|
||||
<Param type="int" name="length" desc="" />
|
||||
</Function>
|
||||
<Function name="TextRemoveSpaces" retType="const char *" paramCount="1" desc="Remove text spaces, concat words">
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
</Function>
|
||||
<Function name="GetTextBetween" retType="char *" paramCount="3" desc="Get text between two strings">
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
<Param type="const char *" name="begin" desc="" />
|
||||
<Param type="const char *" name="end" desc="" />
|
||||
</Function>
|
||||
<Function name="TextReplace" retType="char *" paramCount="3" desc="Replace text string (WARNING: memory must be freed!)">
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
<Param type="const char *" name="replace" desc="" />
|
||||
<Param type="const char *" name="by" desc="" />
|
||||
<Param type="const char *" name="search" desc="" />
|
||||
<Param type="const char *" name="replacement" desc="" />
|
||||
</Function>
|
||||
<Function name="TextReplaceBetween" retType="char *" paramCount="4" desc="Replace text between two specific strings (WARNING: memory must be freed!)">
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
<Param type="const char *" name="begin" desc="" />
|
||||
<Param type="const char *" name="end" desc="" />
|
||||
<Param type="const char *" name="replacement" desc="" />
|
||||
</Function>
|
||||
<Function name="TextInsert" retType="char *" paramCount="3" desc="Insert text in a position (WARNING: memory must be freed!)">
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
@ -2484,14 +2522,14 @@
|
||||
<Param type="char" name="delimiter" desc="" />
|
||||
<Param type="int *" name="count" desc="" />
|
||||
</Function>
|
||||
<Function name="TextAppend" retType="void" paramCount="3" desc="Append text at specific position and move cursor!">
|
||||
<Function name="TextAppend" retType="void" paramCount="3" desc="Append text at specific position and move cursor">
|
||||
<Param type="char *" name="text" desc="" />
|
||||
<Param type="const char *" name="append" desc="" />
|
||||
<Param type="int *" name="position" desc="" />
|
||||
</Function>
|
||||
<Function name="TextFindIndex" retType="int" paramCount="2" desc="Find first text occurrence within a string, -1 if not found">
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
<Param type="const char *" name="find" desc="" />
|
||||
<Param type="const char *" name="search" desc="" />
|
||||
</Function>
|
||||
<Function name="TextToUpper" retType="char *" paramCount="1" desc="Get upper case version of provided string">
|
||||
<Param type="const char *" name="text" desc="" />
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
* - raylib.com/examples/<category>/<category>_example_name.data
|
||||
* - raylib.com/examples/<category>/<category>_example_name.wasm
|
||||
* - raylib.com/examples/<category>/<category>_example_name.js
|
||||
* - ...
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
@ -136,12 +137,12 @@ static const char *exVSProjectSolutionFile = NULL; // Env REXM_EXAMPLES_VS2022_S
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Internal Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
static int FileTextFind(const char *fileName, const char *find);
|
||||
static int FileTextReplace(const char *fileName, const char *find, const char *replace);
|
||||
static int FileCopy(const char *srcPath, const char *dstPath);
|
||||
static int FileRename(const char *fileName, const char *fileRename);
|
||||
static int FileMove(const char *srcPath, const char *dstPath);
|
||||
static int FileRemove(const char *fileName);
|
||||
//static int FileTextFind(const char *fileName, const char *find);
|
||||
//static int FileTextReplace(const char *fileName, const char *find, const char *replace);
|
||||
//static int FileCopy(const char *srcPath, const char *dstPath);
|
||||
//static int FileRename(const char *fileName, const char *fileRename);
|
||||
//static int FileMove(const char *srcPath, const char *dstPath);
|
||||
//static int FileRemove(const char *fileName);
|
||||
|
||||
// Update required files from examples collection
|
||||
// UPDATES: Makefile, Makefile.Web, README.md, examples.js
|
||||
@ -185,9 +186,9 @@ static void UpdateSourceMetadata(const char *exSrcPath, const rlExampleInfo *inf
|
||||
static void UpdateWebMetadata(const char *exHtmlPath, const char *exFilePath);
|
||||
|
||||
// Get text between two strings
|
||||
static char *GetTextBetween(const char *text, const char *begin, const char *end);
|
||||
//static char *GetTextBetween(const char *text, const char *begin, const char *end);
|
||||
// Replace text between two specific strings
|
||||
static char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replace);
|
||||
//static char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replace);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
@ -1773,6 +1774,7 @@ static void UnloadExamplesData(rlExampleInfo *exInfo)
|
||||
RL_FREE(exInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
// Find text in existing file
|
||||
static int FileTextFind(const char *fileName, const char *find)
|
||||
{
|
||||
@ -1808,7 +1810,7 @@ static int FileTextReplace(const char *fileName, const char *textLookUp, const c
|
||||
}
|
||||
|
||||
// Copy file from one path to another
|
||||
// WARNING: Destination path must exist
|
||||
// NOTE: If destination path does not exist, it is created!
|
||||
static int FileCopy(const char *srcPath, const char *dstPath)
|
||||
{
|
||||
int result = 0;
|
||||
@ -1817,10 +1819,13 @@ static int FileCopy(const char *srcPath, const char *dstPath)
|
||||
|
||||
// Create required paths if they do not exist
|
||||
if (!DirectoryExists(GetDirectoryPath(dstPath)))
|
||||
MakeDirectory(GetDirectoryPath(dstPath));
|
||||
result = MakeDirectory(GetDirectoryPath(dstPath));
|
||||
|
||||
if ((srcFileData != NULL) && (srcDataSize > 0))
|
||||
result = SaveFileData(dstPath, srcFileData, srcDataSize);
|
||||
if (result == 0) // Directory created successfully (or already exists)
|
||||
{
|
||||
if ((srcFileData != NULL) && (srcDataSize > 0))
|
||||
result = SaveFileData(dstPath, srcFileData, srcDataSize);
|
||||
}
|
||||
|
||||
UnloadFileData(srcFileData);
|
||||
|
||||
@ -1871,6 +1876,7 @@ static int FileMove(const char *srcPath, const char *dstPath)
|
||||
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
// Get example info from example file header
|
||||
// WARNING: Expecting the example to follow raylib_example_template.c
|
||||
@ -2458,6 +2464,7 @@ static void UpdateWebMetadata(const char *exHtmlPath, const char *exFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Get text between two strings
|
||||
// NOTE: Using static string to return result, MAX: 1024 bytes
|
||||
static char *GetTextBetween(const char *text, const char *begin, const char *end)
|
||||
@ -2515,3 +2522,4 @@ static char *TextReplaceBetween(const char *text, const char *begin, const char
|
||||
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user