* Expose a prompt parameter for use with readline
* Print the prompt if not currently repl-ing through the readline input svn: r4566
This commit is contained in:
parent
a98abdc45f
commit
0ce1ee145e
|
@ -34,6 +34,9 @@ prompt-reading after "rep.ss" installs the new input port.
|
|||
The reading facility that the new input port provides can be
|
||||
customized with these parameters:
|
||||
|
||||
> currnet-prompt
|
||||
The prompt that is used, as a byte string. Defaults to #"> ".
|
||||
|
||||
> show-all-prompts
|
||||
If #f, no prompt is shown until you write input that is completely
|
||||
readable. For example, when you type
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
(require (lib "readline.ss" "readline") (lib "file.ss"))
|
||||
|
||||
;; configuration
|
||||
(define current-prompt (make-parameter #"> "))
|
||||
(define show-all-prompts (make-parameter #t))
|
||||
(define max-history (make-parameter 100))
|
||||
(define keep-duplicates (make-parameter #f))
|
||||
(define keep-blanks (make-parameter #f))
|
||||
(provide show-all-prompts max-history keep-duplicates keep-blanks)
|
||||
(provide current-prompt show-all-prompts
|
||||
max-history keep-duplicates keep-blanks)
|
||||
|
||||
;; History management
|
||||
|
||||
|
@ -132,9 +134,15 @@
|
|||
;; a function that can be used for current-prompt-read
|
||||
(provide read-cmdline-syntax)
|
||||
(define (read-cmdline-syntax)
|
||||
(define prompt (current-prompt))
|
||||
;; needs to set `readline-prompt' to get a prompt when reading
|
||||
(parameterize ([read-accept-reader #t]
|
||||
[readline-prompt #"> "])
|
||||
[readline-prompt prompt])
|
||||
(unless (eq? readline-input (current-input-port))
|
||||
;; not the readline port -- print the prompt (changing the
|
||||
;; readline-prompt and using read-complete-syntax below should still
|
||||
;; work fine)
|
||||
(display prompt) (flush-output))
|
||||
(if (show-all-prompts) (read-syntax) (read-complete-syntax))))
|
||||
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user