169 | | (define (get-input) |
170 | | (if (and C_HAS_MESSAGE_BOX (not (##sys#fudge 4))) ; C_gui_mode |
171 | | (let ((r (dialog |
172 | | str |
173 | | (or title "CHICKEN Runtime") |
174 | | (cond ((string-ci=? default "yes") 0) |
175 | | ((string-ci=? default "no") 1) |
176 | | (else 2))))) |
177 | | (case r |
178 | | ((0) "no") |
179 | | ((1) "yes") |
180 | | (else "abort"))) |
181 | | (string-trim-both (read-line)))) |
182 | | (let loop () |
183 | | (printf "~%~A (yes/no/abort) " str) |
184 | | (when default (printf "[~A] " default)) |
185 | | (flush-output) |
186 | | (let ((ln (get-input))) |
187 | | (cond ((eof-object? ln) (set! ln "abort")) |
188 | | ((and default (string=? "" ln)) (set! ln default)) ) |
189 | | (cond ((string-ci=? "yes" ln) #t) |
190 | | ((string-ci=? "no" ln) #f) |
191 | | ((string-ci=? "abort" ln) (abort)) |
192 | | (else |
193 | | (printf "~%Please enter \"yes\", \"no\" or \"abort\".~%") |
194 | | (loop) ) ) ) ) ) ) ) |
| 170 | (let ((gui (and C_HAS_MESSAGE_BOX (not (##sys#fudge 4))))) ; C_gui_mode |
| 171 | (define (get-input) |
| 172 | (if gui |
| 173 | (let ((r (dialog |
| 174 | str |
| 175 | (or title "CHICKEN Runtime") |
| 176 | (cond ((not default) 3) |
| 177 | ((string-ci=? default "yes") 0) |
| 178 | ((string-ci=? default "no") 1) |
| 179 | (else 2)) |
| 180 | abort))) |
| 181 | (case r |
| 182 | ((0) "no") |
| 183 | ((1) "yes") |
| 184 | (else "abort"))) |
| 185 | (string-trim-both (read-line)))) |
| 186 | (let loop () |
| 187 | (unless gui |
| 188 | (printf "~%~A (yes/no~a) " str (if abort "/abort" "")) |
| 189 | (when default (printf "[~A] " default)) |
| 190 | (flush-output)) |
| 191 | (let ((ln (get-input))) |
| 192 | (cond ((eof-object? ln) (set! ln "abort")) |
| 193 | ((and default (string=? "" ln)) (set! ln default)) ) |
| 194 | (cond ((string-ci=? "yes" ln) #t) |
| 195 | ((string-ci=? "no" ln) #f) |
| 196 | ((and abort (string-ci=? "abort" ln)) (abort)) |
| 197 | (else |
| 198 | (if abort |
| 199 | (printf "~%Please enter \"yes\" or \"no\".~%") |
| 200 | (printf "~%Please enter \"yes\", \"no\" or \"abort\".~%")) |
| 201 | (loop) ) ) ) ) ) ) ) ) |