abort and keyboard-quit
This commit is contained in:
parent
e825073c64
commit
0b6e827e70
|
@ -25,7 +25,9 @@
|
||||||
editor-request-shutdown!
|
editor-request-shutdown!
|
||||||
editor-force-redisplay!
|
editor-force-redisplay!
|
||||||
clear-message
|
clear-message
|
||||||
message)
|
message
|
||||||
|
(struct-out exn:abort)
|
||||||
|
abort)
|
||||||
|
|
||||||
(require racket/match)
|
(require racket/match)
|
||||||
|
|
||||||
|
@ -39,6 +41,8 @@
|
||||||
(require "circular-list.rkt")
|
(require "circular-list.rkt")
|
||||||
(require "file.rkt")
|
(require "file.rkt")
|
||||||
|
|
||||||
|
(struct exn:abort exn (detail) #:transparent)
|
||||||
|
|
||||||
(struct editor (buffers ;; BufferGroup
|
(struct editor (buffers ;; BufferGroup
|
||||||
[tty #:mutable] ;; Tty
|
[tty #:mutable] ;; Tty
|
||||||
[windows #:mutable] ;; (CircularList (List Window SizeSpec)), abstract window layout
|
[windows #:mutable] ;; (CircularList (List Window SizeSpec)), abstract window layout
|
||||||
|
@ -204,9 +208,12 @@
|
||||||
(define (invoke/history cmd)
|
(define (invoke/history cmd)
|
||||||
(define editor (command-editor cmd))
|
(define editor (command-editor cmd))
|
||||||
(clear-message editor)
|
(clear-message editor)
|
||||||
(define result (invoke cmd))
|
(with-handlers* ([exn:abort? (lambda (e)
|
||||||
(set-editor-last-command! editor cmd)
|
(message editor "~a" (exn-message e))
|
||||||
result)
|
(void))])
|
||||||
|
(define result (invoke cmd))
|
||||||
|
(set-editor-last-command! editor cmd)
|
||||||
|
result))
|
||||||
|
|
||||||
(define (editor-last-command? editor . possible-selectors)
|
(define (editor-last-command? editor . possible-selectors)
|
||||||
(and (editor-last-command editor)
|
(and (editor-last-command editor)
|
||||||
|
@ -303,6 +310,11 @@
|
||||||
(invalidate-layout! editor)
|
(invalidate-layout! editor)
|
||||||
(render-editor! editor))
|
(render-editor! editor))
|
||||||
|
|
||||||
|
(define (abort #:detail [detail #f] fmt . args)
|
||||||
|
(raise (exn:abort (apply format fmt args)
|
||||||
|
(current-continuation-marks)
|
||||||
|
detail)))
|
||||||
|
|
||||||
;;---------------------------------------------------------------------------
|
;;---------------------------------------------------------------------------
|
||||||
|
|
||||||
(define-command kernel-mode (save-buffers-kill-terminal buf #:editor ed)
|
(define-command kernel-mode (save-buffers-kill-terminal buf #:editor ed)
|
||||||
|
@ -313,6 +325,10 @@
|
||||||
#:bind-key "C-l"
|
#:bind-key "C-l"
|
||||||
(editor-force-redisplay! ed))
|
(editor-force-redisplay! ed))
|
||||||
|
|
||||||
|
(define-command kernel-mode (keyboard-quit buf)
|
||||||
|
#:bind-key "C-g"
|
||||||
|
(abort "Quit"))
|
||||||
|
|
||||||
(define-command kernel-mode (dump-buffer-to-stderr buf #:window win)
|
(define-command kernel-mode (dump-buffer-to-stderr buf #:window win)
|
||||||
#:bind-key "C-M-x"
|
#:bind-key "C-M-x"
|
||||||
(local-require racket/pretty)
|
(local-require racket/pretty)
|
||||||
|
|
Loading…
Reference in New Issue