diff options
author | Nils Gey <denemo@nilsgey.de> | 2011-02-17 18:45:03 +0100 |
---|---|---|
committer | Nils Gey <denemo@nilsgey.de> | 2011-02-17 18:45:03 +0100 |
commit | 6e20e952c30acc592532b340e93c1675979f0347 (patch) | |
tree | 711d1872b85aaa6efc6d0e4e0168b4ea6a00ba46 | |
parent | 3eafb31715ef21e2aefb41dd907b8f0187f43569 (diff) |
Add ForEachToSelection. Repair NextSelectedObjectAllStaff. Not sure if this fixed the loop
-rw-r--r-- | actions/denemo.scm | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/actions/denemo.scm b/actions/denemo.scm index 15486740..8cba5963 100644 --- a/actions/denemo.scm +++ b/actions/denemo.scm @@ -153,16 +153,15 @@ ;Next object in selection for all staffs (define (NextSelectedObjectAllStaffs) - (define remember 1) + (define lastposition (GetPosition)) (if (and (d-MarkStatus) (d-IsInSelection)) (if (d-NextSelectedObject) #t ; found one. End - (begin (set! remember (d-GetHorizontalPosition)) ; check one staff down and if there is a selection. - (if (d-MoveToStaffDown) + (if (d-MoveToStaffDown) ; no selected item left in the current staff. check one down. (if (selection::MoveToStaffBeginning) #t ; found a selection in the lower staff - (begin (d-GoToPosition #f (- (d-GetStaff) 1) #f remember) #f)) ; reset cursor to the last known selection position - #f))) ; no staff below + (begin (apply d-GoToPosition lastposition ) #f)) ; reset cursor to the last known selection position and end. + #f)) ; no staff below #f)); no selection or cursor not in selection @@ -228,7 +227,7 @@ (begin (eval-string commandsingle)))) ; End of SingleAndSelectionSwitcher -; MapToSelection is like schemes (map) mixed with ApplyToSelection. Use a proc on all selection items and gather all proc return values in a list. +; MapToSelection is like schemes (map) mixed with ApplyToSelection. Use a proc on all selection items and gather all proc return values in a list. You can give an optional test, only items which return #t are processed. (define* (MapToSelection proc #:optional (onlyFor (lambda () #t))) (define return (list #f)) ; prepare return list (define (gather) @@ -239,12 +238,29 @@ (begin (d-PushPosition) (d-GoToSelectionStart) - (gather) ; start one without testing. We already know we have a selection and RepeatProcWhileTest tests first. + (gather) ; start one without selection testing. We already know we have a selection and RepeatProcWhileTest tests first which results in ignoring the first selected item. (RepeatProcWhileTest gather NextSelectedObjectAllStaffs) ; Use the proc/gather function on all items in the selection (d-PopPosition) (list-tail return 1)) #f)) +;ForEachToSelection applies the command to each item in the selection. The return value is unspecified. Faster than MapToSelection. +(define* (ForEachToSelection proc #:optional (onlyFor (lambda () #t))) + (define (apply) + (if (onlyFor) ; test the current item + (proc) + #f)) + (if (and DenemoPref_applytoselection (d-MarkStatus)) ; only if preferences allow it and if there is a selection at all + (begin + (d-PushPosition) + (d-GoToSelectionStart) + (apply) ; start one without selection testing. We already know we have a selection and RepeatProcWhileTest tests first which results in ignoring the first selected item. + (RepeatProcWhileTest apply NextSelectedObjectAllStaffs) ; Use the proc/gather function on all items in the selection + (d-PopPosition) + (if #f #f) ; return unspecified. + ) + #f)) + ; A set of simple tests / questions for score objects. (define (Music?) |