Skip to content

Commit

Permalink
Update amagalma_Move cursor to equivalent position inside next simila…
Browse files Browse the repository at this point in the history
…rly named Region.lua
  • Loading branch information
amagalma authored Feb 6, 2025
1 parent 07e6b3f commit eddb0ef
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
-- @description Move cursor to equivalent position inside next similarly named Region
-- @author amagalma
-- @version 1.00
-- @version 1.01
-- @changelog Slightly changed logic for matching
-- @donation https://www.paypal.me/amagalma

if reaper.GetPlayState() & 4 == 4 then
return reaper.defer(function() end)
end

local cur_pos = reaper.GetCursorPosition()
local cur_region, _ = {}
_, cur_region.idx = reaper.GetLastMarkerAndCurRegion( 0, cur_pos )
Expand All @@ -11,9 +16,9 @@ _, _, cur_region.start, _, cur_region.name = reaper.EnumProjectMarkers( cur_regi
local cur_pos_in_Region = cur_pos - cur_region.start


local function KeepWords(str)
local function KeepLetters(str)
local t, c = {}, 0
for word in str:gmatch("%w+") do
for word in str:gmatch("%a+") do
if not tonumber(word) then
c = c + 1
t[c] = word
Expand All @@ -33,7 +38,7 @@ local function compareStrings(A, B)
return numB >= numA
end

return KeepWords(A) == KeepWords(B)
return KeepLetters(A) == KeepLetters(B)
end


Expand All @@ -52,3 +57,5 @@ while true do
end
i = i + 1
end

reaper.defer(function() end)

0 comments on commit eddb0ef

Please sign in to comment.