ardour/share/scripts/select_regions_at_playhead.lua
luzpaz 52f3986cb6
fix typos in share/scripts directory
Found via `codespell -q 3 -S "*.pdf,*.po,./.git,*.tosc,./waf,./share/patchfiles,./libs,./msvc_extra_headers,./share/web_surfaces,*.patch" -L acount,addin,ane,ba,buss,busses,caf,capela,devine,disconnectin,discreet,doubleclick,envolution,filetest,fo,ghandi,homs,hsi,layed,maschine,mis,nd,ontop,pass-thru,removeable,retrn,ro,scrollin,sectionin,seh,siz,sord,sur,te,trough,ue,wth`
2025-01-12 21:11:16 +01:00

45 lines
1.4 KiB
Lua

ardour { ["type"] = "EditorAction", name = "Select Regions at the Playhead",
license = "MIT",
author = "Ardour Team",
description = [[Select regions under the playhead on selected track(s)]]
}
function factory (params) return function ()
local loc = Session:locations () -- all marker locations
-- get the playhead position
local playhead = Temporal.timepos_t (Session:transport_sample ())
local sl = ArdourUI.SelectionList () -- empty selection list
-- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:Selection
local sel = Editor:get_selection ()
-- Track/Bus Selection -- iterate over all Editor-GUI selected tracks
-- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:TrackSelection
for r in sel.tracks:routelist ():iter () do
-- each of the items 'r' is-a
-- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Route
local track = r:to_track () -- see if it's a track
if track:isnil () then
-- if not, skip it
goto continue
end
-- get track's playlist
-- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Playlist
local playlist = track:playlist ()
for region in playlist:regions_at (playhead):iter () do
local rv = Editor:regionview_from_region (region)
sl:push_back (rv);
end
::continue::
end
-- set/replace current selection in the editor
Editor:set_selection (sl, ArdourUI.SelectionOp.Set);
end end