flushing output on every char input in edit-line

This commit is contained in:
Alex Shinn 2012-05-06 20:13:54 +09:00
parent ee65dad0b3
commit d62ec14dd0

View file

@ -1,6 +1,6 @@
;;;; edit-line.scm - pure scheme line editor ;;;; edit-line.scm - pure scheme line editor
;; ;;
;; Copyright (c) 2011 Alex Shinn. All rights reserved. ;; Copyright (c) 2011-2012 Alex Shinn. All rights reserved.
;; BSD-style license: http://synthcode.com/license.txt ;; BSD-style license: http://synthcode.com/license.txt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -213,7 +213,8 @@
;; move to correct row then col ;; move to correct row then col
(if (< (buffer-row buf) (buffer-max-row buf)) (if (< (buffer-row buf) (buffer-max-row buf))
(terminal-up out (- (buffer-max-row buf) (buffer-row buf)))) (terminal-up out (- (buffer-max-row buf) (buffer-row buf))))
(terminal-goto-col out (buffer-col buf)))) (terminal-goto-col out (buffer-col buf))
(flush-output out)))
(define (buffer-refresh buf out) (define (buffer-refresh buf out)
(cond ((buffer-refresh? buf) (cond ((buffer-refresh? buf)
@ -258,6 +259,7 @@
(not (string-index #\newline x)))) (not (string-index #\newline x))))
;; fast path - append to end of buffer w/o wrapping to next line ;; fast path - append to end of buffer w/o wrapping to next line
(display x out) (display x out)
(flush-output out)
(buffer-col-set! buf (+ (buffer-col buf) len))) (buffer-col-set! buf (+ (buffer-col buf) len)))
(else (else
(buffer-refresh?-set! buf #t))))) (buffer-refresh?-set! buf #t)))))
@ -387,6 +389,7 @@
(define (make-standard-keymap) (define (make-standard-keymap)
(let* ((keymap (make-printable-keymap)) (let* ((keymap (make-printable-keymap))
(v (car keymap))) (v (car keymap)))
(vector-set! v 0 command/enter) ;; for telnet
(vector-set! v 1 command/beggining-of-line) (vector-set! v 1 command/beggining-of-line)
(vector-set! v 2 command/backward-char) (vector-set! v 2 command/backward-char)
(vector-set! v 3 command/cancel) (vector-set! v 3 command/cancel)
@ -406,7 +409,7 @@
(define (keymap-lookup keymap n) (define (keymap-lookup keymap n)
(let ((table (car keymap))) (let ((table (car keymap)))
(or (if (vector? table) (or (if (vector? table)
(and (< n (vector-length table)) (vector-ref table n)) (and (< -1 n (vector-length table)) (vector-ref table n))
(cond ((assv n table) => cdr) (else #f))) (cond ((assv n table) => cdr) (else #f)))
(if (keymap? (cdr keymap)) (if (keymap? (cdr keymap))
(keymap-lookup (cdr keymap) n) (keymap-lookup (cdr keymap) n)
@ -426,7 +429,8 @@
(cond (cond
(((buffer-complete? buf) buf) (((buffer-complete? buf) buf)
(command/end-of-line ch buf out return) (command/end-of-line ch buf out return)
(newline out) (display "\r\n" out)
(flush-output out)
(return)) (return))
(else (else
(command/self-insert ch buf out return))))) (command/self-insert ch buf out return)))))
@ -554,7 +558,8 @@
(flush-output out) (flush-output out)
(if completion (if completion
(vector-set! (car keymap) 9 completion)) (vector-set! (car keymap) 9 completion))
((if (get-key args 'no-stty?:) (lambda (out f) (f)) with-raw-io) ((if (get-key args 'no-stty?:) (lambda (in out f) (f)) with-raw-io)
in
out out
(lambda () (lambda ()
(let lp ((kmap keymap)) (let lp ((kmap keymap))
@ -594,7 +599,8 @@
(history (or (get-key rest 'history:) (make-history)))) (history (or (get-key rest 'history:) (make-history))))
(let ((edit-line (let ((edit-line
(apply make-line-editor 'no-stty?: #t 'history: history rest))) (apply make-line-editor 'no-stty?: #t 'history: history rest)))
((if (get-key args 'no-stty?:) (lambda (out f) (f)) with-raw-io) ((if (get-key args 'no-stty?:) (lambda (in out f) (f)) with-raw-io)
in
out out
(lambda () (lambda ()
(let lp () (let lp ()