1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2025-01-26 03:44:50 +01:00

- added load-script-file.

This commit is contained in:
cage 2021-11-16 16:00:13 +01:00
parent 815ab305a0
commit 5d46a96638
3 changed files with 28 additions and 1 deletions

View File

@ -189,6 +189,8 @@
(define-key "M-e" #'eval-command)
(define-key "M-l" #'load-script-file)
;; focus
(define-key "f1" #'focus-to-tags-window)

View File

@ -2729,7 +2729,8 @@
:gempub-open-file
:message-window-lock-scrolling
:message-window-unlock-scrolling
:eval-command))
:eval-command
:load-script-file))
(defpackage :scheduled-events
(:use

View File

@ -2349,3 +2349,27 @@ example)."
`(lambda () ,(read stream))))))))))))
(ui:ask-string-input #'on-input-completed
:prompt (format nil (_ "eval: ")))))
(defun load-script-callback-event (script-file)
(lambda ()
(tui:with-notify-errors
(db-utils:with-ready-database (:connect nil)
(let ((output (with-output-to-string (stream)
(let ((*standard-output* stream))
(load script-file
:verbose nil
:print nil
:if-does-not-exist :error)))))
(push-event (make-instance 'gemini-display-data-page
:window *message-window*
:payload output)))))))
(defun load-script-file ()
"Asks for a lisp file and execute (in lisp jargon, \"load\") it, the
output of the script (that is the standard output is redirected, and
printed, on the main window."
(flet ((on-input-completed (query)
(push-event (make-instance 'function-event
:payload (load-script-callback-event query)))))
(ui:ask-string-input #'on-input-completed
:prompt (format nil (_ "load file: "))
:complete-fn #'complete:directory-complete)))