mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 14:19:18 +02:00
handling ^C in the repl reader to cancel the current input
This commit is contained in:
parent
4f9a5d7245
commit
e08c0eac45
2 changed files with 12 additions and 4 deletions
|
@ -241,7 +241,7 @@
|
||||||
;;> needed for a terminal application.
|
;;> needed for a terminal application.
|
||||||
|
|
||||||
(define (with-raw-io port thunk)
|
(define (with-raw-io port thunk)
|
||||||
(with-stty '(not icanon echo) thunk port))
|
(with-stty '(not icanon isig echo) thunk port))
|
||||||
|
|
||||||
;;> Returns the current terminal width in characters of @var{x},
|
;;> Returns the current terminal width in characters of @var{x},
|
||||||
;;> which must be a port or a file descriptor.
|
;;> which must be a port or a file descriptor.
|
||||||
|
|
|
@ -336,6 +336,7 @@
|
||||||
(v (car keymap)))
|
(v (car keymap)))
|
||||||
(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 4 command/forward-delete-char)
|
(vector-set! v 4 command/forward-delete-char)
|
||||||
(vector-set! v 5 command/end-of-line)
|
(vector-set! v 5 command/end-of-line)
|
||||||
(vector-set! v 6 command/forward-char)
|
(vector-set! v 6 command/forward-char)
|
||||||
|
@ -377,6 +378,13 @@
|
||||||
(else
|
(else
|
||||||
(command/self-insert ch buf out return)))))
|
(command/self-insert ch buf out return)))))
|
||||||
|
|
||||||
|
(define (command/cancel ch buf out return)
|
||||||
|
(command/end-of-line ch buf out return)
|
||||||
|
(display "^C" out)
|
||||||
|
(newline out)
|
||||||
|
(buffer-delete! buf out 0 (buffer-length buf))
|
||||||
|
(buffer-draw buf out))
|
||||||
|
|
||||||
(define (command/beep ch buf out return)
|
(define (command/beep ch buf out return)
|
||||||
(write-char (integer->char 7) out))
|
(write-char (integer->char 7) out))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue