forked from ReaTeam/ReaScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Unselect hidden tracks (MCP and/or TCP) v1.0 (ReaTeam#156)
* Release Unselect hidden tracks (MCP and/or TCP) v1.0 * sort MCP and TCP in alphabetical order
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-- @description Unselect hidden tracks (MCP and/or TCP) | ||
-- @author cfillion | ||
-- @version 1.0 | ||
-- @metapackage | ||
-- @provides | ||
-- [main] . > cfillion_Unselect tracks hidden in MCP.lua | ||
-- [main] . > cfillion_Unselect tracks hidden in TCP.lua | ||
-- [main] . > cfillion_Unselect tracks hidden in MCP and TCP.lua | ||
-- @link cfillion.ca https://cfillion.ca | ||
-- @donation Donate via PayPal https://paypal.me/cfillion | ||
-- @about | ||
-- This script provides three actions to unselect hidden selected tracks: | ||
-- | ||
-- - cfillion_Unselect tracks hidden in MCP.lua | ||
-- - cfillion_Unselect tracks hidden in TCP.lua | ||
-- - cfillion_Unselect tracks hidden in MCP and TCP.lua | ||
|
||
function enumSelectedTracksReverse() | ||
local i = reaper.CountSelectedTracks(0) | ||
return function() | ||
i = i - 1 | ||
return reaper.GetSelectedTrack(0, i) | ||
end | ||
end | ||
|
||
local TCP = 1<<9 | ||
local MCP = 1<<10 | ||
|
||
local modes = { | ||
['TCP' ] = TCP, | ||
['MCP' ] = MCP, | ||
['MCP and TCP'] = TCP|MCP, | ||
} | ||
|
||
local scriptName = ({reaper.get_action_context()})[2]:match("([^/\\_]+)%.lua$") | ||
local mode = modes[scriptName:match("in (.+)$")] | ||
assert(mode, 'Invalid filename, cannot deduce what to do.') | ||
|
||
reaper.Undo_BeginBlock() | ||
|
||
for track in enumSelectedTracksReverse() do | ||
local _, state = reaper.GetTrackState(track) | ||
|
||
if state & mode == mode then | ||
reaper.SetTrackSelected(track, false) | ||
end | ||
end | ||
|
||
reaper.Undo_EndBlock(scriptName, 1) |