mirror of https://codeberg.org/cage/tinmop/
- [GUI] fixed crash when zooming or unzooming a gemtext window with inlined images.
This commit is contained in:
parent
36e380f31e
commit
83e24a1fda
|
@ -489,9 +489,11 @@
|
|||
(defun inline-possible-p (link-value)
|
||||
(inline-image-p link-value))
|
||||
|
||||
(defun inline-type (link-value)
|
||||
(a:define-constant +inline-ir-type+ :inline-image :test #'eq)
|
||||
|
||||
(defun link-contains-inline-type-p (link-value)
|
||||
(when (inline-image-p link-value)
|
||||
:inline-image))
|
||||
+inline-ir-type+))
|
||||
|
||||
(defun scale-pixmap (main-window file type)
|
||||
(let* ((pixmap (nodgui.pixmap:slurp-pixmap type file))
|
||||
|
@ -536,7 +538,7 @@
|
|||
(gui:move-cursor-to gemtext-widget coordinates)
|
||||
(gui:insert-text gemtext-widget (format nil "~%"))
|
||||
(gui:insert-image gemtext-widget image coordinates)
|
||||
(setf (getf new-line :type) (inline-type link-value))
|
||||
(setf (getf new-line :type) (link-contains-inline-type-p link-value))
|
||||
(setf ir-lines
|
||||
(fresh-vector-insert@ ir-lines
|
||||
new-line
|
||||
|
@ -564,6 +566,10 @@ local file paths."
|
|||
(inline-single-image (ir-lines main-window) (+ line-number 1)))))))
|
||||
(inline-single-image (ir-lines main-window) 1)))
|
||||
|
||||
(defun ir-lines-contains-inlined-images-p (main-window)
|
||||
(find-if (lambda (a) (string= (getf a :type) +inline-ir-type+))
|
||||
(ir-lines main-window)))
|
||||
|
||||
(defun inline-all-images-clsr (main-window)
|
||||
(lambda ()
|
||||
(inline-all-images main-window)))
|
||||
|
@ -1847,20 +1853,39 @@ local file paths."
|
|||
(restart-rendering ,main-window)
|
||||
,@body)))
|
||||
|
||||
(defun uninline-all-images (main-window)
|
||||
(with-accessors ((ir-rendered-lines ir-rendered-lines)
|
||||
(ir-lines ir-lines)) main-window
|
||||
(loop with i = 0 do
|
||||
(if (< i
|
||||
(length ir-lines))
|
||||
(let ((ir-line (elt ir-lines i)))
|
||||
(if (string= (getf ir-line :type) +inline-ir-type+)
|
||||
(progn
|
||||
(setf (ir-lines main-window) (misc:delete@ (ir-lines main-window) i))
|
||||
(setf (ir-rendered-lines main-window)
|
||||
(misc:delete@ (ir-rendered-lines main-window) i)))
|
||||
(incf i)))
|
||||
(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))
|
||||
(ev:with-enqueued-process-and-unblock (program-events:+minimum-event-priority+)
|
||||
(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))))
|
||||
(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
|
||||
|
|
|
@ -2098,7 +2098,7 @@
|
|||
(write-sequence text stream))
|
||||
(croatoan:end-screen)
|
||||
(tui:with-notify-errors
|
||||
(os-utils:open-with-editor temp-file))
|
||||
(os-utils:open-with-editor temp-file))
|
||||
(when (> (fs:file-size temp-file)
|
||||
0)
|
||||
(let ((new-content (fs:slurp-file temp-file)))
|
||||
|
|
Loading…
Reference in New Issue