1 ardour { ["type"] = "EditorAction", name = "Jump to Marker",
3 author = "Ardour Team",
4 description = [[Jump to the first marker matching a given pattern]]
7 function factory () return function ()
12 local dlg = LuaDialog.Dialog ("Search and Jump to Marker",
14 { type = "entry", key = "marker", default = '', title = "Marker Prefix" },
15 { type = "checkbox", key = "keep", default = keep, title = "Keep Dialog Open" },
19 if not rv then return end
23 if (rv['marker'] == "") then
24 if keep then goto restart end
28 for l in Session:locations():list():iter() do
29 if l:is_mark() and string.find (l:name(), "^" .. rv['marker'] .. ".*$") then
30 Session:request_locate (l:start())
31 if keep then goto restart end
36 LuaDialog.Message ("Jump to Marker", "No marker matching the given pattern was found.", LuaDialog.MessageType.Warning, LuaDialog.ButtonType.Close):run ()
38 if keep then goto restart end
42 function icon (params) return function (ctx, width, height, fg)
43 local mh = height - 3.5;
47 ctx:set_line_width (.5)
49 -- compare to gtk2_ardour/marker.cc "Marker"
50 ctx:set_source_rgba (.6, .6, .6, 1.0)
51 ctx:move_to (width / 2 - m6, 2)
52 ctx:rel_line_to (m3, 0)
53 ctx:rel_line_to (0, mh * 0.4)
54 ctx:rel_line_to (-m6, mh * 0.6)
55 ctx:rel_line_to (-m6, -mh * 0.6)
58 ctx:set_source_rgba (.0, .0, .0, 1.0)
61 ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
62 local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(math.min (width, height) * .5) .. "px")
64 local tw, th = txt:get_pixel_size ()
65 ctx:move_to (.5 * (width - tw), .5 * (height - th))
66 txt:show_in_cairo_context (ctx)