From befc9feebf514736f140b50e46f7076ececd3d88 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 29 Apr 2023 18:38:44 +0200 Subject: Add add-sel and toggle-sel --- guile/starlet/open-sound-control/utils.scm | 5 +---- guile/starlet/selection.scm | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'guile') diff --git a/guile/starlet/open-sound-control/utils.scm b/guile/starlet/open-sound-control/utils.scm index 160d9bc..16ccbaf 100644 --- a/guile/starlet/open-sound-control/utils.scm +++ b/guile/starlet/open-sound-control/utils.scm @@ -73,10 +73,7 @@ (define (osc-select-button server button-method addr led fix) (add-osc-method server button-method "" - (lambda () - (if (selected? fix) - (desel fix) - (sel fix)))) + (lambda () (toggle-sel fix))) (add-and-run-hook! selection-hook diff --git a/guile/starlet/selection.scm b/guile/starlet/selection.scm index 32be41a..d0f2c1d 100644 --- a/guile/starlet/selection.scm +++ b/guile/starlet/selection.scm @@ -22,6 +22,8 @@ #:use-module (starlet utils) #:use-module (srfi srfi-1) #:export (sel + add-sel + toggle-sel desel selection-hook get-selection @@ -46,6 +48,21 @@ (run-hook selection-hook selection)) +(define (toggle-sel . fixture-list) + (if (selected? fixture-list) + (desel fixture-list) + (add-sel fixture-list))) + + +(define (add-sel . fixture-list) + (set! selection + (append selection + (filter (lambda (fix) + (not (selected? fix))) + (flatten-sublists fixture-list)))) + (run-hook selection-hook selection)) + + (define (selected? . fixture-list) (every (lambda (fix) (memq fix selection)) -- cgit v1.2.3