Introduction
Introduction Statistics Contact Development Disclaimer Help
Correctly clear line and add progress info - pee - Pee a password manager;Pee -…
git clone git://vernunftzentrum.de/pee.git
Log
Files
Refs
LICENSE
---
commit c3b038dc8581a640505209dddde0142e9510afef
parent d8d114a7059a8e42ebc2fcb1b03cc5c87aad5b64
Author: Christian Kellermann <[email protected]>
Date: Mon, 11 Jan 2016 12:55:43 +0100
Correctly clear line and add progress info
Since reading from /dev/random is slow we add a progress information
string.
Diffstat:
pee.scm | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/pee.scm b/pee.scm
@@ -28,10 +28,12 @@
(define wanted-entropy (* 20 8))
(define (generate-new-password wanted-entropy)
- (define (new-indices len)
- (let loop ((len len)
+ (define (new-indices count)
+ (let loop ((len count)
(idx '()))
- (cond ((zero? len) idx)
+ (clear-line)
+ (printf "~a/~a random bytes recieved.~!" (- count len) count)
+ (cond ((zero? len) (clear-line) idx)
(else
(let ((new (filter (lambda (n)
(< n (string-length password-chars)))
@@ -55,13 +57,17 @@
'(not echo icanon opost)
(lambda ()
(let loop ()
+ (clear-line)
(printf "~a [~a]: " msg (apply string-append options))
(let ((answer (string (read-char))))
(cond ((member answer options) =>
(lambda (c)
- (printf "\r")
+ (clear-line)
(car (string->list (car c)))))
- (else (printf "\r") (loop))))))))
+ (else (loop))))))))
+
+(define (clear-line)
+ (printf "\r~a" (string #\escape #\[ #\K)))
(define (ask-yes-or-no msg)
(eqv? #\y (ask-for-choice msg "y" "n")))
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.