mirror of https://codeberg.org/cage/tinmop/
Compare commits
2 Commits
36e380f31e
...
4b52a02035
Author | SHA1 | Date |
---|---|---|
cage | 4b52a02035 | |
cage | 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
|
||||
|
@ -1986,12 +2011,6 @@ local file paths."
|
|||
(if clockwise
|
||||
(scale-gemtext main-window 0.1)
|
||||
(scale-gemtext main-window -0.1))))
|
||||
:exclusive t)
|
||||
(gui:bind target
|
||||
#$<BackSpace>$
|
||||
(lambda (e)
|
||||
(declare (ignore e))
|
||||
(funcall (back-iri-clsr main-window)))
|
||||
:exclusive t))
|
||||
|
||||
(defun init-main-window (starting-iri)
|
||||
|
|
Loading…
Reference in New Issue