Skip to content

Commit

Permalink
Add double space before rank
Browse files Browse the repository at this point in the history
  • Loading branch information
chmaha committed Jan 3, 2025
1 parent 4e68514 commit 82c4992
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
12 changes: 10 additions & 2 deletions ReaClassical/ReaClassical_Rank Higher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end
function main()
Undo_BeginBlock()
process_items()
Undo_EndBlock("Add '+' suffix to item name", -1)
Undo_EndBlock("Rank Take Higher", -1)
UpdateArrange()
end

Expand All @@ -51,12 +51,20 @@ function modify_item_name(item)
if count_minus > 0 then
item_name = item_name:sub(1, #item_name - 1)
count_minus = count_minus - 1
if count_minus == 0 then
item_name = item_name:gsub(" $", "")
end
else
count_plus = item_name:match("%+*$")
count_plus = count_plus and #count_plus or 0

if count_plus < 3 then
item_name = item_name .. "+"
-- Ensure two spaces before adding the first '+'
if count_plus == 0 and not item_name:find(" +$") then
item_name = item_name:gsub("%s*$", "") .. " +"
else
item_name = item_name .. "+"
end
count_plus = count_plus + 1
end
end
Expand Down
14 changes: 11 additions & 3 deletions ReaClassical/ReaClassical_Rank Lower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end
function main()
Undo_BeginBlock()
process_items()
Undo_EndBlock("Add '-' suffix to item name", -1)
Undo_EndBlock("Rank Take Lower", -1)
UpdateArrange()
end

Expand All @@ -54,12 +54,20 @@ function modify_item_name(item)
if count_plus > 0 then
item_name = item_name:sub(1, #item_name - 1)
count_plus = count_plus - 1
if count_plus == 0 then
item_name = item_name:gsub(" $", "")
end
else
count_minus = item_name:match("%-*$")
count_minus = count_minus and #count_minus or 0

if count_minus < 3 then
item_name = item_name .. "-"
-- Ensure two spaces before adding the first '-'
if count_minus == 0 and not item_name:find(" -$") then
item_name = item_name:gsub("%s*$", "") .. " -"
else
item_name = item_name .. "-"
end
count_minus = count_minus + 1
end
end
Expand All @@ -78,7 +86,7 @@ function modify_item_name(item)
return colors.rank_good
end,
[0] = function()
return 0 -- Default color
return 0 -- Default color
end,
[-1] = function()
return colors.rank_below_average
Expand Down
3 changes: 2 additions & 1 deletion ReaClassical/ReaClassical_Remove Ranking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ end
function main()
reaper.Undo_BeginBlock()
process_items()
reaper.Undo_EndBlock("Remove all '+' and '-' from item name", -1)
reaper.Undo_EndBlock("Remove Take Ranking", -1)
reaper.UpdateArrange()
end

Expand All @@ -47,6 +47,7 @@ function modify_item_name(item)
local _, item_name = reaper.GetSetMediaItemTakeInfo_String(take, "P_NAME", "", false)

item_name = item_name:gsub("[%+%-]+$", "")
item_name = item_name:gsub(" $", "") -- remove double space if present

reaper.GetSetMediaItemTakeInfo_String(take, "P_NAME", item_name, true)

Expand Down

0 comments on commit 82c4992

Please sign in to comment.