fix mistaken "do not roll" conclusion in TransportFSM::compute_should_roll()
[ardour.git] / scripts / s_selection.lua
1 ardour { ["type"] = "Snippet", name = "Editor Selection" }
2
3 function factory () return function ()
4         -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:Selection
5         -- the Ardour Selection can include multiple items
6         -- (regions, tracks, ranges, markers, automation, midi-notes etc)
7         local sel = Editor:get_selection ()
8
9         --
10         -- At the point of writing the following data items are available
11         --
12         
13         -- Range selection, total span of all ranges (0, 0 if no time range is selected)
14         if sel.time:start () < sel.time:end_sample () then
15                 print ("Total Range:", sel.time:start (), sel.time:end_sample ())
16         end
17
18         -- Range selection, individual ranges.
19         for ar in sel.time:iter () do
20                 -- each of the items is a
21                 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:AudioRange
22                 print ("Range:", ar.id, ar.start, ar._end)
23         end
24
25         -- Track/Bus Selection
26         -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:TrackSelection
27         for r in sel.tracks:routelist ():iter () do
28                 -- each of the items is a
29                 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Route
30                 print ("Route:", r:name ())
31         end
32
33         -- Region selection
34         -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:RegionSelection
35         for r in sel.regions:regionlist ():iter () do
36                 -- each of the items is a
37                 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Region
38                 print ("Region:", r:name ())
39         end
40
41         -- Markers
42         -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:MarkerSelection
43         -- Note: Marker selection is not cleared and currently (Ardour-4.7) points
44         --       to the most recently selected marker.
45         for m in sel.markers:iter () do
46                 -- each of the items is a
47                 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOURUI::ArdourMarker
48                 print ("Marker:", m:name (), m:position(), m:_type())
49         end
50
51         ----------------------------------------------------------
52         -- The total time extents of all selected regions and ranges
53         local ok, ext = Editor:get_selection_extents (0, 0)
54         if ok then
55                 print ("Selection Extents:", ext[1], ext[2])
56         else
57                 print ("No region or range is selected")
58         end
59
60 end end