From 76676f2d2ff8908be7a823dce16f3fa203625119 Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 8 Oct 2021 14:35:40 +0200 Subject: [PATCH] - added 'eval-command'; - added docstrings for scroll lock related functions. --- etc/init.lisp | 6 ++++-- src/package.lisp | 3 ++- src/ui-goodies.lisp | 24 ++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/etc/init.lisp b/etc/init.lisp index 64035ed..d1da7fa 100644 --- a/etc/init.lisp +++ b/etc/init.lisp @@ -173,9 +173,11 @@ (define-key "M-up" #'pass-focus-on-top) -(define-key "M-l" #'message-window-lock-scrolling) +(define-key "M-s l" #'message-window-lock-scrolling) -(define-key "M-u" #'message-window-unlock-scrolling) +(define-key "M-s u" #'message-window-unlock-scrolling) + +(define-key "M-e" #'eval-command) ;; focus diff --git a/src/package.lisp b/src/package.lisp index d2f8b32..47368cf 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -2705,7 +2705,8 @@ :gempub-library-window-close :gempub-open-file :message-window-lock-scrolling - :message-window-unlock-scrolling)) + :message-window-unlock-scrolling + :eval-command)) (defpackage :scheduled-events (:use diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 8b7013f..db2afe8 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -2276,9 +2276,29 @@ gemini page the program is rendering." (gemini-viewer:load-gemini-url iri-to-open :give-focus-to-message-window t))) (defun message-window-lock-scrolling () + "Lock automatic scrolling of message window" (setf (message-window:adjust-rows-strategy specials:*message-window*) - #'line-oriented-window:adjust-rows-noop)) + #'line-oriented-window:adjust-rows-noop) + (info-message (_ "Message window scrolling locked"))) (defun message-window-unlock-scrolling () + "Allow automatic scrolling of the message window to always show the +last line (the one on the bottom of the text; useful for chats, for +example)." (setf (message-window:adjust-rows-strategy specials:*message-window*) - #'line-oriented-window:adjust-rows-select-last)) + #'line-oriented-window:adjust-rows-select-last) + (info-message (_ "Message window scrolling unlocked"))) + +(defun eval-command () + "Eval (execute) a lisp form. (e.g '(ui:notify \"foo\")' )" + (flet ((on-input-completed (query) + (push-event (make-instance 'function-event + :payload + (lambda () + (tui:with-notify-errors + (db-utils:with-ready-database (:connect nil) + (with-input-from-string (stream query) + (funcall (compile nil + `(lambda () ,(read stream)))))))))))) + (ui:ask-string-input #'on-input-completed + :prompt (format nil (_ "eval: ")))))