mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-09 22:17:34 +02:00
Control-C in edit-line should kill the process by default.
Adding a convenience keyword to change this to reset the current input as done in the repl.
This commit is contained in:
parent
f252c1bee1
commit
ce7d8505f8
3 changed files with 21 additions and 7 deletions
|
@ -391,7 +391,8 @@
|
|||
'prompt: prompt
|
||||
'history: (repl-history rp)
|
||||
'complete?: buffer-complete-sexp?
|
||||
'completion: (make-sexp-buffer-completer))))))
|
||||
'completion: (make-sexp-buffer-completer)
|
||||
'catch-control-c?: #t)))))
|
||||
|
||||
(define repl-commands
|
||||
`((import . ,repl/import)
|
||||
|
|
|
@ -577,13 +577,14 @@
|
|||
(vector-set! v 127 command/backward-delete-word)
|
||||
keymap))
|
||||
|
||||
(define (make-standard-keymap)
|
||||
(define (make-standard-keymap . o)
|
||||
(let* ((keymap (make-printable-keymap))
|
||||
(v (car keymap)))
|
||||
(v (car keymap))
|
||||
(catch-control-c? (and (pair? o) (car o))))
|
||||
(vector-set! v 0 command/enter) ;; for telnet
|
||||
(vector-set! v 1 command/beginning-of-line)
|
||||
(vector-set! v 2 command/backward-char)
|
||||
(vector-set! v 3 command/cancel)
|
||||
(vector-set! v 3 (if catch-control-c? command/cancel command/quit))
|
||||
(vector-set! v 4 command/forward-delete-char)
|
||||
(vector-set! v 5 command/end-of-line)
|
||||
(vector-set! v 6 command/forward-char)
|
||||
|
@ -635,6 +636,13 @@
|
|||
(buffer-delete! buf out 0 (buffer-length buf))
|
||||
(buffer-draw buf out))
|
||||
|
||||
(define (command/quit ch buf out return)
|
||||
(command/end-of-line ch buf out return)
|
||||
(display "^C" out)
|
||||
(newline out)
|
||||
(stty out '(icanon isig echo))
|
||||
(exit))
|
||||
|
||||
(define (command/beep ch buf out return)
|
||||
(write-char (integer->char 7) out))
|
||||
|
||||
|
@ -717,6 +725,7 @@
|
|||
;; line-editing
|
||||
|
||||
(define standard-keymap (make-standard-keymap))
|
||||
(define standard-cancel-keymap (make-standard-keymap #t))
|
||||
|
||||
(define (get-key ls key . o)
|
||||
(let ((x (memq key ls)))
|
||||
|
@ -737,7 +746,10 @@
|
|||
(terminal-width (get-key args 'terminal-width:))
|
||||
(single-line? (get-key args 'single-line?: #f))
|
||||
(no-stty? (get-key args 'no-stty?: #f))
|
||||
(keymap0 (get-key args 'keymap: standard-keymap))
|
||||
(keymap0 (get-key args 'keymap:
|
||||
(if (get-key args 'catch-control-c?: #f)
|
||||
standard-cancel-keymap
|
||||
standard-keymap)))
|
||||
(keymap (if completion
|
||||
(cons (list (cons 9 completion)) keymap0)
|
||||
keymap0))
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
history-commit! history->list list->history buffer->string
|
||||
make-buffer buffer-make-completer
|
||||
buffer-clear buffer-refresh buffer-draw
|
||||
buffer-row buffer-col)
|
||||
(import (chibi) (chibi stty) (srfi 9) (srfi 33))
|
||||
buffer-row buffer-col
|
||||
make-keymap make-standard-keymap)
|
||||
(import (chibi) (chibi stty) (chibi process) (srfi 9) (srfi 33))
|
||||
(include "edit-line.scm"))
|
||||
|
|
Loading…
Add table
Reference in a new issue