[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Denemo-devel] Flexa
From: |
Andreas Schneider |
Subject: |
[Denemo-devel] Flexa |
Date: |
Sun, 29 Jan 2017 11:00:13 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 |
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] Flexa,
Andreas Schneider <=