Copie les noms de régions depuis l'entrée (au format script Croissants) vers des noms de régions Reaper.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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