summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2024-04-13 18:44:42 +0300
committerjussi2024-04-13 18:44:42 +0300
commit1d66edf4f2390c25485ef4205b20c184de1c2f5d (patch)
tree7a3cd79e26d7b93a2fb4a3764171fbe90d22a9d4
parentb96960a1f97f815a6872fedc422ea950ed477cda (diff)
downloadreilua-enhanced-1d66edf4f2390c25485ef4205b20c184de1c2f5d.tar.gz
reilua-enhanced-1d66edf4f2390c25485ef4205b20c184de1c2f5d.tar.bz2
reilua-enhanced-1d66edf4f2390c25485ef4205b20c184de1c2f5d.zip
Position argument added for GetCodepoint, GetCodepointNext and GetCodepointPrevious.
-rw-r--r--API.md6
-rw-r--r--CMakeLists.txt6
-rw-r--r--ReiLua_API.lua9
-rw-r--r--changelog1
-rw-r--r--cmake/EnumOption.cmake14
-rw-r--r--examples/2D_lights/main.lua8
-rw-r--r--examples/raygui_examples/calculator.lua4
-rw-r--r--examples/raygui_examples/file_browser.lua13
-rw-r--r--examples/resources/lib/pubsub.lua24
-rw-r--r--examples/resources/lib/utillib.lua3
-rw-r--r--src/text.c15
11 files changed, 67 insertions, 36 deletions
diff --git a/API.md b/API.md
index 21217a5..42af261 100644
--- a/API.md
+++ b/API.md
@@ -6864,7 +6864,7 @@ Get total number of codepoints in a UTF-8 encoded string
---
-> codepoint, codepointSize = RL.GetCodepoint( string text )
+> codepoint, codepointSize = RL.GetCodepoint( string text, int position )
Get codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
@@ -6872,7 +6872,7 @@ Get codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
---
-> codepoint, codepointSize = RL.GetCodepointNext( string text )
+> codepoint, codepointSize = RL.GetCodepointNext( string text, int position )
Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
@@ -6880,7 +6880,7 @@ Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
---
-> codepoint, codepointSize = RL.GetCodepointPrevious( string text )
+> codepoint, codepointSize = RL.GetCodepointPrevious( string text, int position )
Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 094dd67..830795b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,8 +17,8 @@ option( LUA_EVENTS "Enable Lua event callbacks (RL.event)." off )
enum_option( PLATFORM "Desktop;Desktop_SDL;Web" "Platform to build for." )
if( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
- set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
- set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
+ set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
+ set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
endif()
file( GLOB SOURCES src/*.c )
@@ -45,7 +45,7 @@ if( PLATFORM STREQUAL "Web" )
# Try "-s USE_PTHREADS" if not getting pixel perfect rendering.
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY" )
# set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s FORCE_FILESYSTEM=1" )
- set( CMAKE_EXECUTABLE_SUFFIX ".html" ) # This line is used to set your executable to build with the emscripten html template so that you can directly open it.
+ set( CMAKE_EXECUTABLE_SUFFIX ".html" ) # This line is used to set your executable to build with the emscripten html template so that you can directly open it.
set( resources_dir "resources@/" ) # Sets resources as root for the virtual file system.
set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}" )
else() # Desktop
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index 4802b7f..aa2e956 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -4151,23 +4151,26 @@ function RL.GetCodepointCount( text ) end
---Get codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
---- Success return int, int
---@param text string
+---@param position integer
---@return any codepoint
---@return any codepointSize
-function RL.GetCodepoint( text ) end
+function RL.GetCodepoint( text, position ) end
---Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
---- Success return int, int
---@param text string
+---@param position integer
---@return any codepoint
---@return any codepointSize
-function RL.GetCodepointNext( text ) end
+function RL.GetCodepointNext( text, position ) end
---Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
---- Success return int, int
---@param text string
+---@param position integer
---@return any codepoint
---@return any codepointSize
-function RL.GetCodepointPrevious( text ) end
+function RL.GetCodepointPrevious( text, position ) end
---Encode one codepoint into UTF-8 byte array
---- Success return string
diff --git a/changelog b/changelog
index a8bf02f..5fe4b68 100644
--- a/changelog
+++ b/changelog
@@ -37,6 +37,7 @@ DETAILED CHANGES:
- ADDED: PubSub lib.
- ADDED: Raygui lib tree view.
- ADDED: Raygui lib examples file browser.
+ - CHANGE: Position argument added for GetCodepoint, GetCodepointNext and GetCodepointPrevious.
------------------------------------------------------------------------
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
diff --git a/cmake/EnumOption.cmake b/cmake/EnumOption.cmake
index d7d343f..d3cfbae 100644
--- a/cmake/EnumOption.cmake
+++ b/cmake/EnumOption.cmake
@@ -1,9 +1,9 @@
macro(enum_option var values description)
- set(${var}_VALUES ${values})
- list(GET ${var}_VALUES 0 default)
- set(${var} "${default}" CACHE STRING "${description}")
- set_property(CACHE ${var} PROPERTY STRINGS ${${var}_VALUES})
- if (NOT ";${${var}_VALUES};" MATCHES ";${${var}};")
- message(FATAL_ERROR "Unknown value ${${var}}. Only -D${var}=${${var}_VALUES} allowed.")
- endif()
+ set(${var}_VALUES ${values})
+ list(GET ${var}_VALUES 0 default)
+ set(${var} "${default}" CACHE STRING "${description}")
+ set_property(CACHE ${var} PROPERTY STRINGS ${${var}_VALUES})
+ if (NOT ";${${var}_VALUES};" MATCHES ";${${var}};")
+ message(FATAL_ERROR "Unknown value ${${var}}. Only -D${var}=${${var}_VALUES} allowed.")
+ endif()
endmacro()
diff --git a/examples/2D_lights/main.lua b/examples/2D_lights/main.lua
index 847f5b2..34bf8bc 100644
--- a/examples/2D_lights/main.lua
+++ b/examples/2D_lights/main.lua
@@ -12,6 +12,8 @@ local LIGHTRENDER_SIZE = 1024 -- Maxinum light size.
local SHADOW_FOV = 45 -- Camera fov for shadow rendering.
local WALL_MESH_HEIGHT = math.tan( RL.DEG2RAD * ( 90 - SHADOW_FOV / 2 ) ) * LIGHTRENDER_SIZE / TILE_SIZE_PX / 2
+print( "WALL_MESH_HEIGHT", WALL_MESH_HEIGHT )
+
local monitor = 0
local monitorPos = Vector2:new( RL.GetMonitorPosition( monitor ) )
local monitorSize = Vector2:new( RL.GetMonitorSize( monitor ) )
@@ -24,7 +26,7 @@ local lightTexSize = Vector2:new()
local framebuffer = nil
local lightMap = nil -- Final image of all lights.
local lightRender = nil -- RenderTexture for individual light and shadow rendering.
-local ambientLight = Color:new( 40, 40, 40, 255 )
+local ambientLight = Color:new( 40, 40, 40 )
local wallSegs = {}
local shadowMesh = nil
local lights = {}
@@ -131,10 +133,10 @@ function RL.init()
RL.rlDisableBackfaceCulling()
end
--- Process.
+-- Update.
function RL.update( delta )
- lights[1].pos = Vector2:new( RL.GetMousePosition() )
+ lights[1].pos:set( RL.GetMousePosition() )
end
-- Drawing.
diff --git a/examples/raygui_examples/calculator.lua b/examples/raygui_examples/calculator.lua
index 78253c0..6274a0b 100644
--- a/examples/raygui_examples/calculator.lua
+++ b/examples/raygui_examples/calculator.lua
@@ -11,9 +11,9 @@ Calculator.OPERATIONS = {
}
function Calculator:new( pos )
- local object = setmetatable( {}, Calculator )
+ local object = setmetatable( {}, Calculator )
- object.window = Gui:WindowBox(
+ object.window = Gui:WindowBox(
Rect:new( pos.x, pos.y, 188, 216 ),
"Calculator",
{ -- Callbacks.
diff --git a/examples/raygui_examples/file_browser.lua b/examples/raygui_examples/file_browser.lua
index cdecfb0..df6f244 100644
--- a/examples/raygui_examples/file_browser.lua
+++ b/examples/raygui_examples/file_browser.lua
@@ -22,7 +22,7 @@ FileBrowser.FILE_ICONS = {
}
function FileBrowser:new( pos )
- local object = setmetatable( {}, FileBrowser )
+ local object = setmetatable( {}, FileBrowser )
object.padding = 4
object.spacing = 4
@@ -34,7 +34,7 @@ function FileBrowser:new( pos )
local textButtonSize = Vec2:new( 72, 28 )
-- Window.
- object.window = Gui:WindowBox(
+ object.window = Gui:WindowBox(
Rect:new( pos.x, pos.y, winSize.x, winSize.y ),
"File Browser",
{ -- callbacks.
@@ -182,7 +182,7 @@ function FileBrowser:new( pos )
return object
end
-function FileBrowser:popup( mode, path, callback )
+function FileBrowser:popup( mode, path, callback, filters )
self:setPath( path )
self.mode = mode
@@ -191,6 +191,10 @@ function FileBrowser:popup( mode, path, callback )
self.callbacks.ok = callback
end
+ if filters ~= nil then
+ self.filterDropdown.text = "All\n"..filters
+ end
+
self:setVisible( true )
end
@@ -266,7 +270,7 @@ function FileBrowser:updateList()
-- Search.
if self.searchText == "" or ( 0 < #self.searchText
- and self.searchText:lower() == record.name:sub( 1, #self.searchText ):lower() ) then
+ and -1 < RL.TextFindIndex( record.name:lower(), self.searchText:lower() ) ) then
table.insert( self.files, record )
end
end
@@ -351,7 +355,6 @@ function FileBrowser:setFilter()
end
self:updateList()
- print( "self.filter", self.filter )
end
function FileBrowser:setPosition( pos )
diff --git a/examples/resources/lib/pubsub.lua b/examples/resources/lib/pubsub.lua
index 2847d92..47d9a63 100644
--- a/examples/resources/lib/pubsub.lua
+++ b/examples/resources/lib/pubsub.lua
@@ -13,21 +13,33 @@ function PubSub:add( name )
self.signals[ name ] = {}
end
+function PubSub:remove( name )
+ if self.signals[ name ] ~= nil then
+ table.remove( self.signals, name )
+ end
+end
+
function PubSub:subscribe( name, func )
- table.insert( self.signals[ name ], func )
+ if self.signals[ name ] ~= nil then
+ table.insert( self.signals[ name ], func )
+ end
end
function PubSub:unSubscribe( name, uFunc )
- for i, func in ipairs( self.signals[ name ] ) do
- if func == uFunc then
- table.remove( self.signals[ name ], i )
+ if self.signals[ name ] ~= nil then
+ for i, func in ipairs( self.signals[ name ] ) do
+ if func == uFunc then
+ table.remove( self.signals[ name ], i )
+ end
end
end
end
function PubSub:publish( name, ... )
- for _, func in ipairs( self.signals[ name ] ) do
- func( ... )
+ if self.signals[ name ] ~= nil then
+ for _, func in ipairs( self.signals[ name ] ) do
+ func( ... )
+ end
end
end
diff --git a/examples/resources/lib/utillib.lua b/examples/resources/lib/utillib.lua
index 73bb11c..a661f60 100644
--- a/examples/resources/lib/utillib.lua
+++ b/examples/resources/lib/utillib.lua
@@ -7,7 +7,8 @@ end
local utillib = {}
-function utillib.tableClone( org )
+-- Does not work with dictionaries.
+function utillib.arrayClone( org )
return { table.unpack( org ) }
end
diff --git a/src/text.c b/src/text.c
index f4ed7a2..0b0a3c3 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1086,7 +1086,7 @@ int ltextGetCodepointCount( lua_State* L ) {
}
/*
-> codepoint, codepointSize = RL.GetCodepoint( string text )
+> codepoint, codepointSize = RL.GetCodepoint( string text, int position )
Get codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
@@ -1094,6 +1094,9 @@ Get codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
*/
int ltextGetCodepoint( lua_State* L ) {
const char* text = luaL_checkstring( L, 1 );
+ int position = luaL_checkinteger( L, 2 );
+
+ text += position;
int codepointSize = 0;
lua_pushinteger( L, GetCodepoint( text, &codepointSize ) );
@@ -1103,7 +1106,7 @@ int ltextGetCodepoint( lua_State* L ) {
}
/*
-> codepoint, codepointSize = RL.GetCodepointNext( string text )
+> codepoint, codepointSize = RL.GetCodepointNext( string text, int position )
Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
@@ -1111,6 +1114,9 @@ Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
*/
int ltextGetCodepointNext( lua_State* L ) {
const char* text = luaL_checkstring( L, 1 );
+ int position = luaL_checkinteger( L, 2 );
+
+ text += position;
int codepointSize = 0;
lua_pushinteger( L, GetCodepointNext( text, &codepointSize ) );
@@ -1120,7 +1126,7 @@ int ltextGetCodepointNext( lua_State* L ) {
}
/*
-> codepoint, codepointSize = RL.GetCodepointPrevious( string text )
+> codepoint, codepointSize = RL.GetCodepointPrevious( string text, int position )
Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
@@ -1128,6 +1134,9 @@ Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failu
*/
int ltextGetCodepointPrevious( lua_State* L ) {
const char* text = luaL_checkstring( L, 1 );
+ int position = luaL_checkinteger( L, 2 );
+
+ text += position;
int codepointSize = 0;
lua_pushinteger( L, GetCodepointPrevious( text, &codepointSize ) );