Skip to content
Extraits de code Groupes Projets
Vérifiée Valider fc95056f rédigé par Kubat's avatar Kubat
Parcourir les fichiers

SCRIPT: Update specification

parent d4219041
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Ce commit fait partie de la requête de fusion !16. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
...@@ -16,12 +16,10 @@ ...@@ -16,12 +16,10 @@
Create a new script. All the options and other stuff is defined in the Create a new script. All the options and other stuff is defined in the
`.spek` file. `.spek` file.
local script = Vivy:newScript { local script = Vivy:newScript ("sample_script")
name = "sample_script", author = "Vivy", revision = "rev-1254"
}
A local function to the script may be used by another script with the A local function to the script may be used by another script with the
"Vivy:getScript" function call. "Vivy:import" function call.
All job functions take as first parameter the opt structure. This is really All job functions take as first parameter the opt structure. This is really
usefull when calling multiple scripts on the same Vivy document with a usefull when calling multiple scripts on the same Vivy document with a
...@@ -30,25 +28,20 @@ ...@@ -30,25 +28,20 @@
]] ]]
local global = Vivy:global () local global = Vivy:global ()
local utils = Vivy:getScript { script = "utils", author = "std" } local script = Vivy:newScript ("sample-spec")
local script = Vivy:newScript { local utils = Vivy:import { script = "utils" }
name = "sample_script", local prettyPrint = Vivy:import { script = "utils", func = "prettyPrint" }
author = "Vivy",
revision = "rev-1254",
}
Vivy:newFunction ("tripleCopySyl", function (syl) local tripleCopySyl = Vivy:newFunction ("tripleCopySyl", function (syl)
return { syl:copy(), syl:copy(), syl:copy() } return { syl:copy(), syl:copy(), syl:copy() }
end) end)
Vivy:newFunction ("printFoo", function () Vivy:newFunction ("printFoo", function () print "Bar" end)
print "Bar"
end)
Vivy:newJob ("retime_lines", Iterable.LINE, function (opt, line) Vivy:newJob ("retime_lines", Iterable.LINE, function (opt, line)
line.start += opt.preTime line.start += opt.preTime
line.finish += opt.postTime line.finish += opt.postTime
if line.start <= 0 then line.start = 0; end if line.start <= 0 then line.start = 0 end
if line.finish >= global.finish() then line.finish = global.finish() end if line.finish >= global.finish() then line.finish = global.finish() end
return line return line
end) end)
......
-- The name and description of the script. Spaces and column `:` characters in -- vim: ft=lua
-- the script name are illegal. Comments begin by `--`. DeclareScript {
|> sample-spec name = [[ sample-spec ]],
#(Sample script use for the specification) description = [[ Sample script used for the specification proposition ]],
file = [[ sample-spec.lua ]],
-- Set some usefull informations author = [[ Vivy ]],
file <- sample-spec.lua revision = [[ rev-1254 ]],
author <- Vivy imports = { "utils" },
revision <- rev-1254 options = {
"custom-opt" = { option1 = false },
-- Register option tipes "time-opt" = { preTime = -900, postTime = 300, },
#{custom-opt} "color-opt" = { color1 = Vivy:newColor("#314159") }
optin1 : boolean -> false },
functions = {
#{time-opt} DeclareFunctopn { name = "tripleCopySyl" },
preTime : integer -> -900 DeclareFunction { name = "printFoo" },
postTime : integer -> 300 ImportFunction { name = "prettyPrint", script = "utils" },
},
#{color-opt} jobs = {
color1 : color -> Vivy:newColor("#314159") DeclareJob { name = "set_retime", options = { "time-opt" } },
DeclareJob { name = "demultiply_syllabes" },
-- Register used job functions. Here the `sample-spec:` is implied. ImportJob { name = "color_after_read_3", script = "utils", options = { "color-opt" } }
@set_retime#{time-opt} }
@demultiply_syllabes }
@utils:color_after_read_3#{color-opt}
-- Here we have the free functions defined in the script, a comma-separated
-- list, thus comma and spaces and brackets in function names are not allowed.
#[tripleCopySyl, printFoo]
-- vim: ft=
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter