Position argument added for GetCodepoint, GetCodepointNext and GetCodepointPrevious.
This commit is contained in:
6
API.md
6
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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
15
src/text.c
15
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 ) );
|
||||
|
||||
Reference in New Issue
Block a user