Rename prompt-shown' ->
zero-column!', and use it only in the
non-readline reader. Use line reading for ,install!.
This commit is contained in:
parent
3a1dde7f14
commit
3f8bb7a453
|
@ -85,11 +85,11 @@
|
|||
(flush-output last-output-port)
|
||||
(define-values [line col pos] (port-next-location last-output-port))
|
||||
(unless (eq? col 0) (newline)))
|
||||
(define (prompt-shown)
|
||||
;; right after an input expression is entered the terminal won't show the
|
||||
;; newline, so as far as column counting goes it's still after the prompt
|
||||
;; which leads to bad output in practice. (at least in the common case where
|
||||
;; IO share the same terminal.)
|
||||
(define (zero-column!)
|
||||
;; there's a problem whenever there's some printout followed by a read: the
|
||||
;; cursor will at column zero, but the port counting will think that it's
|
||||
;; still right after the printout; call this function in such cases to adjust
|
||||
;; the column to 0.
|
||||
(maybe-new-output-port)
|
||||
(define-values [line col pos] (port-next-location last-output-port))
|
||||
(set-port-next-location! last-output-port line 0 pos))
|
||||
|
@ -1009,6 +1009,7 @@
|
|||
(define expr "(require xrepl)")
|
||||
(define dexpr "(dynamic-require 'xrepl #f)")
|
||||
(define contents (file->string init-file))
|
||||
(read-line) ; discard the newline for further input
|
||||
(define (look-for comment-rx expr)
|
||||
(let ([m (regexp-match-positions
|
||||
(format "(?<=\r?\n|^) *;+ *~a *\r?\n *~a *(?=\r?\n|$)"
|
||||
|
@ -1018,9 +1019,7 @@
|
|||
(define existing? (look-for (regexp-quote comment) expr))
|
||||
(define existing-readline?
|
||||
(look-for "load readline support[^\r\n]*" "(require readline/rep)"))
|
||||
(define (yes?)
|
||||
(flush-output)
|
||||
(begin0 (regexp-match? #rx"^[yY]" (getarg 'string)) (prompt-shown)))
|
||||
(define (yes?) (flush-output) (regexp-match? #rx"^[yY]" (getarg 'line)))
|
||||
(cond
|
||||
[existing?
|
||||
(printf "; already installed, nothing to do\n")
|
||||
|
@ -1175,7 +1174,7 @@
|
|||
(provide make-command-reader)
|
||||
(define (make-command-reader)
|
||||
(define (plain-reader prefix) ; a plain reader, without readline
|
||||
(display prefix) (display "> ") (flush-output)
|
||||
(display prefix) (display "> ") (flush-output) (zero-column!)
|
||||
(let ([in ((current-get-interaction-input-port))])
|
||||
((current-read-interaction) (object-name in) in)))
|
||||
(define RL ; no direct dependency on readline
|
||||
|
@ -1221,7 +1220,7 @@
|
|||
(define input
|
||||
(if from-queue?
|
||||
(begin0 (car more-inputs) (set! more-inputs (cdr more-inputs)))
|
||||
(begin (fresh-line) (begin0 (reader (get-prefix)) (prompt-shown)))))
|
||||
(begin (fresh-line) (reader (get-prefix)))))
|
||||
(syntax-case input ()
|
||||
[(uq cmd) (eq? 'unquote (syntax-e #'uq))
|
||||
(let ([r (run-command (syntax->datum #'cmd))])
|
||||
|
|
Loading…
Reference in New Issue
Block a user