Skip to content

Instantly share code, notes, and snippets.

@Signez
Last active March 19, 2018 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Signez/287c89e71d7aa780353fbaa4e5e60f83 to your computer and use it in GitHub Desktop.
Save Signez/287c89e71d7aa780353fbaa4e5e60f83 to your computer and use it in GitHub Desktop.
Copie les noms de régions depuis l'entrée (au format script Croissants) vers des noms de régions Reaper.
clipboard = reaper.ExecProcess("/bin/bash -c \"" ..
"LC_ALL=fr_FR.UTF-8 /usr/bin/pbpaste | " ..
"/usr/bin/iconv -f utf8 -t ascii//TRANSLIT//IGNORE | " ..
"tr -d \\' | tr -d \\`\"", 1000)
lines = {}
linesCount = 0
for s in clipboard:gmatch("[^\r\n]+") do
if s:match "^%-%-" then
result, _ = s:gsub("^%-%-[ ]*", "", 1)
table.insert(lines, result)
linesCount = linesCount + 1
end
end
_, _, regionsCount = reaper.CountProjectMarkers(0)
if regionsCount == linesCount then
i=0
repeat
retval, isrgn, pos, rgnend, name, markrgnindexnumber, color = reaper.EnumProjectMarkers3(0,i)
if retval >= 1 then
if lines[i+1] then
reaper.SetProjectMarker3(0, markrgnindexnumber, isrgn, pos, rgnend, lines[i+1], color)
end
i = i+1
end
until retval == 0
reaper.ShowMessageBox("Noms de régions appliqués.", "C'est fait !", 0)
else
if linesCount > 0 then
reaper.ShowMessageBox("Il existe une incohérence entre le nombre de lignes lues du presse papier et le nombre de régions.\n" ..
string.format("%d lignes pour %d régions.\n%s", linesCount, regionsCount, table.concat(lines, "\n")),
"Incohérence relevée : rien n’a été fait.", 0)
else
reaper.ShowMessageBox("Éxécutez ce script en ayant copié le contenu complet du script dans le presse papier.\n" ..
"Chaque ligne débutant par deux tirets sera utilisée pour nommer les régions.", "Ceci est un script d'autonommage de régions.", 0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment