/usr/share/denemo/actions/denemo-modules/moveandsearch.scm is in denemo-data 2.0.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | ;Find the next object that returns #t from the given test function. Don't write the function in parentheses, just give the name (except you give a function that returns a name :))
(define (FindNextObjectAllStaffs test?)
(let loopy ()
(if (d-NextObject)
(if (test?)
#t ; object found. Stop
(loopy)) ; not the droids you're looking for, move on
(if (d-MoveToStaffDown); no next object possible
(begin (d-MoveToBeginning) ; lower staff found
(if (test?)
#t; object found. Stop
(loopy))) ; first object of lower staff is not a member, start search again.
#f) ; no staff left, final end.
); if end
));loopy end
;;finds the next note at or above the cusor satisfying test?,
(define (FindNextNoteAllColumns test?)
(let loop ()
(if (MeasureEnd?)
(if (d-GoToPosition #f (1+ (d-GetStaff)) #f 1) ; try to go a staff down
(begin ; there is a staff down. Loop again
(d-CursorToNthNoteHeight 1)
(loop))
(begin ; there is no staff down.
(if (d-GoToPosition #f 1 (1+ (d-GetMeasure)) 1) ; try to go to the next column
(begin
(d-CursorToNthNoteHeight 1)
(loop)) ; there is a next column. Start at lowest note and Loop again
#f))) ; there is none, end of the movement. End of the script
(if (test?)
#t ; object found. stop
(begin
(if (d-CursorToNextNoteHeight)
(loop)
(if (d-MoveCursorRight)
(d-CursorToNthNoteHeight 1)))
(loop) )))))
(define (FindNextObjectAllColumns test?)
(if (not (MeasureEnd?))
(d-MoveCursorRight))
(let loop ()
(if (MeasureEnd?)
(if (d-GoToPosition #f (1+ (d-GetStaff)) #f 1) ; try to go a staff down
(loop) ; there is a staff down. Loop again
(begin ; there is no staff down.
(if (d-GoToPosition #f 1 (1+ (d-GetMeasure)) 1) ; try to go to the next column
(loop) ; there is a next column. Loop again
#f))) ; there is none, end of the movement. End of the script
(if (test?)
#t ; object found. stop
(begin
(d-MoveCursorRight)
(loop))))))
(define (FindPrevObjectAllColumns test?)
(define (step)
(if (not (MeasureBeginning?))
(d-MoveCursorLeft)
(if (d-GoToPosition #f (1- (d-GetStaff)) #f 1) ; try to go a staff up
(GoToMeasureEnd)
(if (and (MoveToColumnEnd) (d-GoToPosition #f #f (1- (d-GetMeasure)) 1)) ; no staff above. try to go to the previous column
(GoToMeasureEnd)
#f)))) ; no previous column
;;Body
(step)
(let loop ()
(if (test?)
#t
(if (step)
(loop)
(begin (d-MoveToMovementBeginning) #f))))); Beginning of Movement, end of search
;TODO: Rewrite to not use their own loop but the other functions in this file.
(define (PrevDirectiveOfTag tag)
(let loop ()
(if (d-PrevStandaloneDirective)
(if (not (d-Directive-standalone? tag))
(loop)
#t
)
#f)))
;TODO: Rewrite to not use their own loop but the other functions in this file.
(define (NextDirectiveOfTag tag)
(let loop ()
(if (d-NextStandaloneDirective)
(if (not (d-Directive-standalone? tag))
(loop)
#t
)
#f)))
(define (NextDirectiveOfTagInMeasure tag)
(d-PushPosition)
(let loop ()
(if (d-NextStandaloneDirectiveInMeasure)
(if (not (d-Directive-standalone? tag))
(loop)
(begin
(d-PopPushPosition)
(d-PopPosition)
#t))
(begin
(d-PopPosition)
#f))))
(define (PrevDirectiveOfTagInMeasure tag)
(d-PushPosition)
(let loop ()
(if (d-PrevStandaloneDirectiveInMeasure)
(if (not (d-Directive-standalone? tag))
(loop)
(begin
(d-PopPushPosition)
(d-PopPosition)
#t))
(begin
(d-PopPosition)
#f))))
; GoToMeasureEnd: Move right until "appending" or "none" which is the Measure End
(define (GoToMeasureEnd)
(let loop ()
(if (or (None?) (Appending?))
#t
(begin (d-MoveCursorRight) (loop)))))
; GoToMeasureBeginning
(define (GoToMeasureBeginning)
(if (d-MoveToMeasureLeft)
(d-MoveToMeasureRight)
(d-MoveToBeginning)))
; Go to the first staff, same measure. Handle crossing unequal staff length.
(define (MoveToColumnStart)
(define measure (d-GetMeasure)) ; to make shure we stay in the same column all the time.
(RepeatUntilFail d-MoveToStaffUp)
(d-GoToPosition #f #f measure #f))
(define (MoveToColumnEnd)
(define measure (d-GetMeasure)) ; to make shure we stay in the same column all the time.
(RepeatUntilFail d-MoveToStaffDown)
(d-GoToPosition #f #f measure #f))
(define (GetPosition)
(list (d-GetMovement) (d-GetStaff) (d-GetMeasure)(d-GetHorizontalPosition)))
(define (PositionEqual? position1 position2)
(and (equal? (list-ref position1 0) (list-ref position2 0))
(equal? (list-ref position1 1) (list-ref position2 1))
(equal? (list-ref position1 2) (list-ref position2 2))
(equal? (list-ref position1 3) (list-ref position2 3))))
(define (Probe test moveinstruction)
(define return #f)
(d-PushPosition)
(if (moveinstruction)
(set! return (test)))
(d-PopPosition)
return)
(define (ProbePosition test movement staff measure horizontalposition)
(Probe test (lambda () (d-GoToPosition movement staff measure horizontalposition))))
(define (ProbePreviousMeasure test)
(Probe test d-MoveToMeasureLeft))
(define (ProbeNextMeasure test)
(Probe test d-MoveToMeasureRight))
(define (ProbeNextObject test)
(Probe test d-NextObject))
(define (ProbePreviousObject test)
(Probe test d-PreviousObject))
(define (ProbeNextNote test)
(Probe test d-NextNote))
(define (ProbePreviousNote test)
(Probe test d-PreviousNote))
(define (MoveDownStaffOrVoice)
(if (d-MoveToVoiceDown)
#t
(d-MoveToStaffDown)))
(define (MoveUpStaffOrVoice)
(if (d-MoveToVoiceUp)
#t
(d-MoveToStaffUp)))
(define (LastMovement?) (not (Probe (lambda () #t) d-NextMovement)))
(define (FirstMovement?) (not (Probe (lambda () #t) d-PreviousMovement)))
|