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

- made the program asks for redirects following only when the event

queue is empty;
- added 'gemini-request-event';
- minor refactoring.
This commit is contained in:
cage 2020-06-27 22:43:13 +02:00
parent 44701669b5
commit 62d3356e78
5 changed files with 30 additions and 9 deletions

View File

@ -47,6 +47,7 @@
(db-utils:with-ready-database (:connect nil)
(request new-url))))))
(ui:ask-string-input #'on-input-complete
:priority program-events:+minimum-event-priority+
:prompt
(format nil
(_ "Redirects to ~s, follows redirect? [y/N] ")

View File

@ -87,6 +87,11 @@ etc.) happened"
(defun reset-timeline-pagination ()
(ui:reset-timeline-pagination))
(defun load-gemini-url (url)
(let* ((refresh-event (make-instance 'program-events:gemini-request-event
:url url)))
(program-events:push-event refresh-event)))
(defun load-configuration-files ()
(swconf:load-config-file swconf:+shared-conf-filename+)
(swconf:load-config-file swconf:+conf-filename+))
@ -117,9 +122,7 @@ etc.) happened"
(client:init)
(client:authorize)
(if command-line:*gemini-url*
(progn
(gemini-viewer:request *gemini-url*)
(ui:focus-to-message-window))
(load-gemini-url command-line:*gemini-url*)
(progn
(let ((program-events:*process-events-immediately* t))
(when command-line:*start-timeline*

View File

@ -1194,6 +1194,7 @@
:report-status-event
:add-crypto-data-event
:poll-vote-event
:gemini-request-event
:function-event
:dispatch-program-events
:add-pagination-status-event

View File

@ -179,8 +179,10 @@
set the payload of this events with the user provided string."))
(defmethod initialize-instance :after ((object ask-user-input-string-event)
&key &allow-other-keys)
(setf (priority object) (truncate (/ +standard-event-priority+ 2))))
&key (forced-priority nil) &allow-other-keys)
(if forced-priority
(setf (priority object) forced-priority)
(setf (priority object) (truncate (/ +standard-event-priority+ 2)))))
(defmethod process-event ((object ask-user-input-string-event))
(with-accessors ((prompt prompt)
@ -190,6 +192,7 @@
object)
(setf (point-tracker:prompt specials:*command-window*)
prompt)
(command-window:remove-messages specials:*command-window*)
(setf complete:*complete-function* complete-fn)
(command-window:set-string-mode specials:*command-window*)
(command-window:set-history-most-recent specials:*command-window* prompt)
@ -887,6 +890,17 @@
(tui:with-notify-errors
(api-client:poll-vote poll-id choices))))
(defclass gemini-request-event (program-event)
((url
:initform nil
:initarg :url
:accessor url)))
(defmethod process-event ((object gemini-request-event))
(with-accessors ((url url)) object
(ui:focus-to-message-window)
(gemini-viewer:request url)))
(defclass function-event (program-event) ())
(defmethod process-event ((object function-event))

View File

@ -142,15 +142,17 @@
(defun ask-string-input (on-input-complete-fn
&key
(priority nil)
(initial-value nil)
(prompt +default-command-prompt+)
(complete-fn #'complete:directory-complete))
(flet ((thread-fn ()
(let ((event (make-instance 'ask-user-input-string-event
:initial-value initial-value
:complete-fn complete-fn
:prompt prompt
:payload (box:dbox nil))))
:forced-priority priority
:initial-value initial-value
:complete-fn complete-fn
:prompt prompt
:payload (box:dbox nil))))
(with-accessors ((lock lock)
(condition-variable condition-variable)) event
(push-event event)