line-read: #:suspend? #f makes C-z ring the bell
A shell must not stop itself at its prompt. With #:suspend? #f, C-z rings the bell instead of stopping the program. The default is #t, as before. The manifest comment no longer names glue/Keys.cs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
566008e264
commit
590ac3b853
3 changed files with 13 additions and 6 deletions
15
src/line.bjo
15
src/line.bjo
|
|
@ -64,6 +64,7 @@
|
|||
(: input-done? (Option (-> string bool)))
|
||||
(: history-size int)
|
||||
(: reflow? (Option bool))
|
||||
(: suspend? bool)
|
||||
(: history (Vec string) #:mutable))))
|
||||
|
||||
;; Reverse search through the history.
|
||||
|
|
@ -105,6 +106,8 @@
|
|||
;; - `#:input-done?`: called by Enter with the whole input. #f makes Enter
|
||||
;; start a new line; a REPL returns #f while brackets are open.
|
||||
;; - `#:history-size`: the most entries kept; the oldest go first.
|
||||
;; - `#:suspend?`: whether C-z stops the program. A shell sets #f; C-z
|
||||
;; then rings the bell.
|
||||
;; - `#:reflow?`: whether the terminal wraps its lines again when it gets
|
||||
;; narrower. None uses `terminal-reflows?`. A wrong #t can erase output
|
||||
;; above the input when the terminal narrows; a wrong #f leaves a copy of
|
||||
|
|
@ -113,10 +116,12 @@
|
|||
(#:input-done? (Option (-> string bool)))
|
||||
(#:history-size int)
|
||||
(#:reflow? (Option bool))
|
||||
(#:suspend? bool)
|
||||
LineEditor))
|
||||
(defun (make-line-editor #:completer None #:input-done? None #:history-size 1000 #:reflow? None)
|
||||
(defun (make-line-editor #:completer None #:input-done? None #:history-size 1000 #:reflow? None
|
||||
#:suspend? #t)
|
||||
(LineEditor (completer completer) (input-done? input-done?)
|
||||
(history-size history-size) (reflow? reflow?) (history [])))
|
||||
(history-size history-size) (reflow? reflow?) (suspend? suspend?) (history [])))
|
||||
|
||||
;; The history, oldest first.
|
||||
(: (-> LineEditor (Vec string)))
|
||||
|
|
@ -199,8 +204,8 @@
|
|||
;; - Tab completes with `#:completer`, and a second Tab lists the
|
||||
;; candidates. Without a completer it inserts a tab.
|
||||
;; - Enter accepts (see `#:input-done?`), M-Enter and C-j start a new line,
|
||||
;; C-l clears the screen, C-z stops the program, C-c cancels, and C-d on
|
||||
;; an empty buffer is end of input.
|
||||
;; C-l clears the screen, C-z stops the program (see `#:suspend?`),
|
||||
;; C-c cancels, and C-d on an empty buffer is end of input.
|
||||
(: (-> LineEditor Terminal string (#:continuation (Option string)) LineResult))
|
||||
(defun (line-read ed term prompt #:continuation None)
|
||||
(def cont (match continuation
|
||||
|
|
@ -791,5 +796,5 @@
|
|||
((Tuple KeyTab (Tuple #f #f)) (complete ed st (record-ref prev tabbed?)))
|
||||
((Tuple (KeyChar #\i) (Tuple #t #f)) (complete ed st (record-ref prev tabbed?)))
|
||||
((Tuple (KeyChar #\l) (Tuple #t #f)) (ClearScreen st))
|
||||
((Tuple (KeyChar #\z) (Tuple #t #f)) (SuspendNow st))
|
||||
((Tuple (KeyChar #\z) (Tuple #t #f)) (if (record-ref ed suspend?) (SuspendNow st) (Bell st)))
|
||||
(_ (Bell st))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue