I have written a new version of the flexa script. It is based on Richard's script that creates a flexa from two selected notes. I have added a toggle behaviour, i.e. if you activate it where a flexa is already present, it is deleted. The script saves in the data field where the beginning and the end of the flexa is. Here is the code:
(let ((tag "Flexa")) (if (d-Directive-chord? tag) (begin ; a flexa directive already exists -> delete it (disp "Deleting existing flexa ...") (disp "Cursor is at flexa " (d-DirectiveGet-chord-data tag)) (if (string=? (d-DirectiveGet-chord-data tag) "Start") ; if it's the start of a flexa (begin (disp "Deleting felxa from start") (d-DirectiveDelete-chord tag) (d-NextChord) (d-DirectiveDelete-chord tag) ) (begin ; if it's the end of a flexa (disp "Deleting flexa from end") (d-DirectiveDelete-chord tag) (d-PrevChord) (d-DirectiveDelete-chord tag)))) (begin ; no Flexa directive exists yet -> create a flexa (disp "Creating a flexa ...") (if (and (not (d-HasSelection)) (d-PrevChord)) (begin (d-SetMark) (d-NextChord) (d-SetPoint))) (if (MoveToSelectionBeginningInThisStaff) (begin (d-DirectivePut-chord-prefix tag "\\[ ") (d-DirectivePut-chord-postfix tag "\\flexa ") (d-DirectivePut-chord-display tag "fl--") (d-DirectivePut-chord-override tag 16) (d-DirectivePut-chord-data tag "Start") (if (d-NextChord) (begin (d-DirectivePut-chord-postfix tag "\\] ") (d-DirectivePut-chord-display tag "--]") (d-DirectivePut-chord-override tag 16))) (d-DirectivePut-chord-data tag "End") (d-MoveCursorRight) (d-SetSaved #f)) (d-WarningDialog (_ "You must select two notes")))))) It still contains some debug output which you can remove. Andreas _______________________________________________ Denemo-devel mailing list Denemo-devel@gnu.org https://lists.gnu.org/mailman/listinfo/denemo-devel