guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

readline eats previous text on line


From: Jon Wilson
Subject: readline eats previous text on line
Date: Wed, 27 Sep 2006 16:26:13 -0500
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050324)

Hi,
I'm trying to read user input (interactive) using guile. I'd like to use (ice-9 readline), so that the user can use backspace and history and such. I'd also like to have a prompt at the beginning of the line. These last two desires seem to be incompatible, at least mod my best efforts.

For instance, please consider the following:

(use-modules (ice-9 rdelim) (ice-9 format) (ice-9 readline))
(activate-readline)

(define (test)
  (define str #f)
  (display "prompt: ")
  (let loop ((n 1000000))
        (if (not (zero? n)) (loop (1- n))))
  (set! str (read-line))
  (newline)
  (display str))

(test)

This prints "prompt: " on a line, and then after a short time, it is erased. The mess with loop in the middle is of course a crufty time delay, without which I can't see "prompt: " at all before it disappears. After it has disappeared, I can type whatever I like, and then press enter. Whatever I have typed is then printed as expected, on a new line.

This behavior is unchanged (except for how much text is actually read) when I substitute read-char or read in for read-line.

This behavior is gone when I remove (activate-readline).

However, without readline, as I said above, the user cannot backspace, which is a great annoyance.

Obviously, however, when the normal guile repl uses readline, it has a prompt which is not eaten. How is this accomplished?

Regards,
Jon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]