denemo-devel
[Top][All Lists]
Advanced

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

Re: [Denemo-devel] Flexa


From: Richard Shann
Subject: Re: [Denemo-devel] Flexa
Date: Sun, 29 Jan 2017 11:24:41 +0000

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.

Richard

> 
> (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
> address@hidden
> https://lists.gnu.org/mailman/listinfo/denemo-devel





reply via email to

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