[Wisp-cvs] wisp/users/pisi whiptail.wisp,NONE,1.1
Status: Alpha
Brought to you by:
digg
From: <pi...@us...> - 2003-04-13 17:26:01
|
Update of /cvsroot/wisp/wisp/users/pisi In directory sc8-pr-cvs1:/tmp/cvs-serv18507 Added Files: whiptail.wisp Log Message: capture-alternate for whiptail --- NEW FILE: whiptail.wisp --- ;;; alternate pipe reader ;;; whiptail prints selected items to stderr ;;; and requires stdout to be a tty (in case i want to see anything, what i do) ;;; solution - make an alternate pipe reader ;;; should this be incorporated to unix.wim someday/somehow ? (use unix files syscalls semiraw-files) (define (make-pipe-close-hook pid) (lambda (port read? write?) (if (and read? write?) (begin (sys:close (file-descriptor port)) ; FIXME: the fd slot should be NULLed too. (sys:waitpid pid 0))))) (define (pipe-alternate-from proc (num 2)) (let* ((pipe (sys:pipe)) (child (sys:fork))) (if (zero? child) ; child (begin (sys:close (car pipe)) (sys:dup2 (cdr pipe) num) (sys:close (cdr pipe)) (dedicated proc)) ; parent (begin (sys:close (cdr pipe)) (my res (make-instance <old-file>) (init-input-file res (car pipe) (make-pipe-close-hook child)) res))))) (define (capture-alternate-lines proc num) (my p (pipe-alternate-from proc num) (hold (read-all-lines p) (close-input-port p)))) ;;; test (write (capture-alternate-lines "whiptail --noitem --separate-output --title Test --menu Select 20 20 10 tag1 item1 tag2 item2" 2)) (newline) (write (capture-alternate-lines "whiptail --noitem --separate-output --title Test --checklist checkbox 20 40 10 tag1 on tag2 on \"long tag1\" on \"long tag2\" on" 2)) (newline) |