|
@ -68,6 +68,21 @@ |
|
|
(λ (a b) |
|
|
(λ (a b) |
|
|
(regexp-match? (regexp (format "^~a$" a)) b))) |
|
|
(regexp-match? (regexp (format "^~a$" a)) b))) |
|
|
|
|
|
|
|
|
|
|
|
;;function to run when a chdir command is received |
|
|
|
|
|
(define (chdir-command dir args) |
|
|
|
|
|
;; if the command fails to run with the updated directory |
|
|
|
|
|
;; then say so, and continue running |
|
|
|
|
|
(with-handlers ([exn:fail? |
|
|
|
|
|
(λ (_) |
|
|
|
|
|
(display |
|
|
|
|
|
(format "No such directory ~a" |
|
|
|
|
|
(car dir))) |
|
|
|
|
|
(play '() played args))]) |
|
|
|
|
|
(current-directory (car dir)) |
|
|
|
|
|
(update! (play-list)) |
|
|
|
|
|
(play (play-list) played args))) |
|
|
|
|
|
|
|
|
|
|
|
; the reactor procedure for commands |
|
|
(define (play-react previous-files played args cmd next) |
|
|
(define (play-react previous-files played args cmd next) |
|
|
(define (continue-playing new-prev args res) |
|
|
(define (continue-playing new-prev args res) |
|
|
(play-react (append new-prev args res) |
|
|
(play-react (append new-prev args res) |
|
@ -85,10 +100,7 @@ |
|
|
[(remove-command s resources) (remove* resources previous-files playlist-remove?) |
|
|
[(remove-command s resources) (remove* resources previous-files playlist-remove?) |
|
|
(continue-playing new-previous args resources)] |
|
|
(continue-playing new-previous args resources)] |
|
|
|
|
|
|
|
|
[(chdir s directory) |
|
|
[(chdir s directory) (chdir-command directory args)] |
|
|
(current-directory (car directory)) |
|
|
|
|
|
(update! (play-list)) |
|
|
|
|
|
(play (play-list) played args)] |
|
|
|
|
|
|
|
|
|
|
|
[(modify s name new-content) s] |
|
|
[(modify s name new-content) s] |
|
|
|
|
|
|
|
@ -97,6 +109,7 @@ |
|
|
['() (inner '())] |
|
|
['() (inner '())] |
|
|
[_ (inner (cdr previous-files))]))) |
|
|
[_ (inner (cdr previous-files))]))) |
|
|
|
|
|
|
|
|
|
|
|
;; the main play procedure |
|
|
(define (play fnames played args) |
|
|
(define (play fnames played args) |
|
|
(cond ((null? fnames) |
|
|
(cond ((null? fnames) |
|
|
(let* ([new-data (thread-receive)]) |
|
|
(let* ([new-data (thread-receive)]) |
|
@ -119,6 +132,7 @@ |
|
|
new-data |
|
|
new-data |
|
|
thread-try-receive)]))))) |
|
|
thread-try-receive)]))))) |
|
|
|
|
|
|
|
|
|
|
|
;; the procedure to control the command line thingy |
|
|
(define (controller player-thread) |
|
|
(define (controller player-thread) |
|
|
(cond |
|
|
(cond |
|
|
((compose not thread-running?) player-thread ; if the thread is not running then return |
|
|
((compose not thread-running?) player-thread ; if the thread is not running then return |
|
|