diff --git a/scripts/fetch-post-tree.lisp b/scripts/fetch-post-tree.lisp new file mode 100644 index 0000000..79638e5 --- /dev/null +++ b/scripts/fetch-post-tree.lisp @@ -0,0 +1,51 @@ +;; tinmop module for utility move command in thread window +;; Copyright © 2022 cage + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +(defpackage :fetch-post-tree + (:use + :cl + :misc + :fs + :text-utils + :specials + :program-events + :ui-goodies) + (:local-nicknames (:a :alexandria))) + +(in-package :fetch-post-tree) + +(if (ui:tui-active-p) + (labels ((on-input-complete (status-id) + (with-enqueued-process () + (if (string-not-empty-p status-id) + (let* ((timeline (thread-window:timeline-type *thread-window*)) + (folder (thread-window:timeline-folder *thread-window*)) + (expand-event (make-instance 'expand-thread-event + :force-saving-of-ignored-status t + :new-folder folder + :new-timeline timeline + :status-id status-id)) + (refresh-event (make-instance 'refresh-thread-windows-event + :priority +minimum-event-priority+ + :message-status-id status-id))) + (notify "Fetching data") + (push-event expand-event) + (push-event refresh-event) + (notify "Data fetched")) + (error-message "ID empty"))))) + (ui:ask-string-input #'on-input-complete + :prompt "Type the post's ID: ")) + (format *error-output* "This script needs can not be ran from the command line.~%")) diff --git a/src/package.lisp b/src/package.lisp index 99b8dd4..868c045 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1525,6 +1525,7 @@ :add-pagination-status-event :status-id :timeline + :display-output-script-page :gemini-display-data-page :gemini-request-event :gemini-back-event diff --git a/src/program-events.lisp b/src/program-events.lisp index 45d89f4..e0a9408 100644 --- a/src/program-events.lisp +++ b/src/program-events.lisp @@ -1079,6 +1079,20 @@ (tui:with-notify-errors (api-client:poll-vote poll-id choices)))) +(defclass display-output-script-page (program-event) + ((window + :initform nil + :initarg :window + :accessor window))) + +(defmethod process-event ((object display-output-script-page)) + (with-accessors ((page-data payload) + (window window)) object + (when (text-utils:string-not-empty-p page-data) + (tui:with-notify-errors + (message-window:prepare-for-rendering window page-data) + (windows:draw window))))) + (defclass gemini-display-data-page (program-event) ((window :initform nil diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index 466b3e9..067c52d 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -2717,7 +2717,7 @@ example)." :verbose nil :print nil :if-does-not-exist :error))))) - (push-event (make-instance 'gemini-display-data-page + (push-event (make-instance 'display-output-script-page :window *message-window* :payload output))))))) (defun load-script-file ()