1
0
Fork 0

- added nested expansion of 'with-enqueued-process-and-unblock' and 'enqueue-request-and-wait-results'.

This commit is contained in:
cage 2024-07-31 18:15:49 +02:00
parent 4b52a02035
commit 769fbf26f0
3 changed files with 34 additions and 23 deletions

View File

@ -1869,23 +1869,24 @@ local file paths."
(return-from uninline-all-images t)))))
(defun scale-gemtext (main-window offset)
(let ((saved-active-stream (find-streaming-stream-url)))
(interrupt-rendering main-window)
(maybe-stop-streaming-stream-thread)
(when saved-active-stream
(open-iri (streaming-url saved-active-stream) main-window t))
(let ((contains-inlined-images (ir-lines-contains-inlined-images-p main-window)))
(when contains-inlined-images
(uninline-all-images main-window))
(restart-rendering main-window)
(clear-gemtext main-window)
(setf (gemtext-font-scaling main-window)
(if offset
(max 0.1 (+ (gemtext-font-scaling main-window) offset))
1.0))
(render-ir-lines (get-address-bar-text main-window) main-window)
(when contains-inlined-images
(inline-all-images main-window)))))
(ev:with-enqueued-process-and-unblock ()
(let ((saved-active-stream (find-streaming-stream-url)))
(interrupt-rendering main-window)
(maybe-stop-streaming-stream-thread)
(when saved-active-stream
(open-iri (streaming-url saved-active-stream) main-window t))
(let ((contains-inlined-images (ir-lines-contains-inlined-images-p main-window)))
(when contains-inlined-images
(uninline-all-images main-window))
(restart-rendering main-window)
(clear-gemtext main-window)
(setf (gemtext-font-scaling main-window)
(if offset
(max 0.1 (+ (gemtext-font-scaling main-window) offset))
1.0))
(render-ir-lines (get-address-bar-text main-window) main-window)
(when contains-inlined-images
(inline-all-images main-window))))))
(defun initialize-keybindings (main-window target)
(gui:bind target

View File

@ -34,6 +34,9 @@
,@on-error)))
(defun enqueue-request-and-wait-results (method-name id priority &rest args)
(ev:push-function-and-wait-results (lambda () (apply #'comm:make-request method-name id args))
:push-event-fn #'ev:push-event-unblock
:priority priority))
(if program-events::*already-enqueued*
(apply #'comm:make-request method-name id args)
(ev:push-function-and-wait-results (lambda ()
(apply #'comm:make-request method-name id args))
:push-event-fn #'ev:push-event-unblock
:priority priority)))

View File

@ -249,10 +249,17 @@
:payload (lambda () ,@body)
:priority ,priority)))
(defparameter *already-enqueued* nil)
(defmacro with-enqueued-process-and-unblock ((&optional (priority +standard-event-priority+)) &body body)
`(push-event-unblock (make-instance 'function-event
:payload (lambda () ,@body)
:priority ,priority)))
`(if *already-enqueued*
(funcall (lambda () ,@body))
(push-event-unblock (make-instance 'function-event
:payload
(lambda ()
(let ((*already-enqueued* t))
,@body))
:priority ,priority))))
(defclass event-on-own-thread (program-event)
((lock