Commits

Moritz Heidkamp committed 840aa1c

chicken-select: remove stty and use read-line to allow for more than 10 chickens (thanks Mario Goulart for the patch)

  • Participants
  • Parent commits ee2e259

Comments (0)

Files changed (2)

File chicken-belt.meta

  (author "Christian Kellermann, Moritz Heidkamp")
  (category tools)
  (license "BSD")
- (depends matchable stty))
+ (depends matchable))

File chicken-select.scm

 #!/usr/bin/csi -s
 
-(use srfi-1 posix stty)
+(use srfi-1 posix)
 (include "chicken-env")
 
 (assert-chicken-coop-exists)
                     all-chicks
                     (iota (length all-chicks)))
           (newline)
-          (print "Select a new Chicken, press ENTER to abort:")
-          (let* ((choice-raw (with-stty '(cbreak (not echo)) read-char))
-                 (num (string->number (string choice-raw))))
-            (if (and 
-                 num
-                 (<= 0 num)
-                 (< num (length all-chicks)))
-                (begin
-                  (print "Setting current Chicken to " (list-ref all-chicks num))
-                  (set-current-chicken (list-ref all-chicks
-                                                 num)
-                                       chicken-link))
-                (select choice-raw)))))))
+          (print* "Select a new Chicken, press ENTER to abort: ")
+          (let ((choice-raw (read-line)))
+            (if (equal? choice-raw "")
+                (exit)
+                (let ((num (string->number choice-raw)))
+                  (if (and
+                       num
+                       (<= 0 num)
+                       (< num (length all-chicks)))
+                      (begin
+                        (print "Setting current Chicken to " (list-ref all-chicks num))
+                        (set-current-chicken (list-ref all-chicks
+                                                       num)
+                                             chicken-link))
+                      (select choice-raw)))))))))