denemo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Denemo-devel] Flexa


From: Andreas Schneider
Subject: Re: [Denemo-devel] Flexa
Date: Sun, 29 Jan 2017 21:21:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

Am 29.01.2017 um 12:24 schrieb Richard Shann:
> On Sun, 2017-01-29 at 11:00 +0100, Andreas Schneider wrote:
>> 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:
> 
> A couple of suggestions:
> 
> since you are just needing a boolean in the data field I suggest you
> store a value only for the flexa start, and delete the line
> 
> 
> (d-DirectivePut-chord-data tag "End") 
> 
> so then the bit of your script:
> 
> (if (string=? (d-DirectiveGet-chord-data tag) "Start") ; if it's thestart of 
> a flexa
> 
> can become simply:
> 
> (if (d-DirectiveGet-chord-data tag)    ; if it's thestart of a flexa
> 
> Also, it will be more conventional to use 
> 
> (d-DirectivePut-chord-data tag "'start")
> 
> rather than "Start" when creating the flexa start directive.
> It makes no difference what the string is, as long as it is not white
> space, but as this field is designated as holding Scheme data then
> storing a symbol there looks good.

Thank you for your suggestions. I have updated my script accordingly:

(let ((tag "Flexa"))

(if (d-Directive-chord? tag)
        (begin ; a flexa directive already exists -> delete it
        (if (d-DirectiveGet-chord-data tag) ; if it's the start of a flexa
                (begin
                        (d-DirectiveDelete-chord tag)
                        (d-NextChord)
                        (d-DirectiveDelete-chord tag))
                (begin ; if it's the end of a flexa
                        (d-DirectiveDelete-chord tag)
                        (d-PrevChord)
                        (d-DirectiveDelete-chord tag))))
        (begin ; no Flexa directive exists yet -> create 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-MoveCursorRight)
                        (d-SetSaved #f))
                (d-WarningDialog (_ "You must select two notes"))))))

If this is okay, I would create a similar script for pes.

Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]