mirror of
https://codeberg.org/cage/tinmop/
synced 2024-12-22 23:47:56 +01:00
- [GUI] made the TOC's resize its width to fits the TOC items width.
- [GUI] added configuration directive for TOC width limits; - [GUI] refactored TOC rendering code; - [GUI] clear TOC widget from legacy items befor rendering the new TOC.
This commit is contained in:
parent
d61656e0ad
commit
2982dfdeeb
@ -158,7 +158,9 @@ gemini.preformatted.justification = center
|
||||
|
||||
# width in chars
|
||||
|
||||
toc.width = 30
|
||||
toc.maximum.width = 80
|
||||
|
||||
toc.minimum.width = 20
|
||||
|
||||
toc.font = Monospace
|
||||
|
||||
|
@ -210,12 +210,22 @@
|
||||
|
||||
(gen-conf-justification gemini swconf:+key-preformatted-text+)
|
||||
|
||||
(swconf:gen-simple-access (toc-width
|
||||
(swconf:gen-simple-access (toc-maximum-width
|
||||
:transform-value-fn (lambda (a)
|
||||
(truncate (or (num-utils:safe-parse-number a)
|
||||
20)))
|
||||
:configuration-tree *client-configuration*)
|
||||
swconf:+key-toc+
|
||||
swconf:+key-maximum+
|
||||
swconf:+key-width+)
|
||||
|
||||
(swconf:gen-simple-access (toc-minimum-width
|
||||
:transform-value-fn (lambda (a)
|
||||
(truncate (or (num-utils:safe-parse-number a)
|
||||
80)))
|
||||
:configuration-tree *client-configuration*)
|
||||
swconf:+key-toc+
|
||||
swconf:+key-minimum+
|
||||
swconf:+key-width+)
|
||||
|
||||
(defun toc-font-configuration ()
|
||||
|
@ -112,6 +112,22 @@
|
||||
(with-notify-errors
|
||||
(apply #'comm:make-request method-name id args))))
|
||||
|
||||
(defun render-toc (main-window iri)
|
||||
(with-notify-errors
|
||||
(toc-clear main-window)
|
||||
(let* ((toc-max-width (gui-conf:config-toc-maximum-width))
|
||||
(toc (comm:make-request :gemini-table-of-contents
|
||||
1
|
||||
iri
|
||||
toc-max-width)))
|
||||
(when toc
|
||||
(let ((toc-widget-width (length (getf (first toc) :text))))
|
||||
(setf (toc-char-width main-window) toc-widget-width)
|
||||
(loop for ct from 0
|
||||
for toc-item in toc do
|
||||
(gui:listbox-append (toc-listbox (toc-frame main-window))
|
||||
(getf toc-item :text))))))))
|
||||
|
||||
(defun slurp-gemini-stream (main-window iri stream-wrapper &key
|
||||
(use-cache t)
|
||||
(process-function #'identity)
|
||||
@ -139,20 +155,8 @@
|
||||
(loop-fetch (+ last-lines-fetched-count
|
||||
next-start-fetching))))))))
|
||||
(loop-fetch)
|
||||
(let ((gui:*wish* gui-goodies:*gui-server*))
|
||||
(let* ((toc-widget-width (gui:cget (gui:listbox (toc-listbox (toc-frame main-window)))
|
||||
:width))
|
||||
(toc-width (parse-integer toc-widget-width))
|
||||
(toc (cev:enqueue-request-and-wait-results :gemini-table-of-contents
|
||||
1
|
||||
ev:+standard-event-priority+
|
||||
iri
|
||||
toc-width)))
|
||||
(misc:dbg "toc ~a" toc-width)
|
||||
(loop for ct from 0
|
||||
for toc-item in toc do
|
||||
(gui:listbox-append (toc-listbox (toc-frame main-window))
|
||||
(getf toc-item :text)))))))
|
||||
(ev:with-enqueued-process-and-unblock ()
|
||||
(render-toc main-window iri))))
|
||||
|
||||
(defun start-streaming-thread (main-window iri
|
||||
&key
|
||||
@ -705,7 +709,7 @@
|
||||
(setf toc-listbox (make-instance 'gui:scrolled-listbox
|
||||
:master object
|
||||
:name nil))
|
||||
(gui:configure (gui:listbox toc-listbox) :width (gui-conf:config-toc-width))
|
||||
(gui:configure (gui:listbox toc-listbox) :width (gui-conf:config-toc-minimum-width))
|
||||
(gui:configure (gui:listbox toc-listbox)
|
||||
:font (gui-conf:toc-font-configuration))
|
||||
(gui:grid toc-listbox 0 0
|
||||
@ -777,6 +781,20 @@
|
||||
(gui:focus (nodgui.mw:autocomplete-entry-widget (iri-entry (tool-bar object))))
|
||||
object))
|
||||
|
||||
(defgeneric toc-char-width (object))
|
||||
|
||||
(defgeneric toc-clear (object))
|
||||
|
||||
(defmethod toc-char-width ((object main-frame))
|
||||
(gui:cget (gui:listbox (toc-listbox (toc-frame object)))
|
||||
:width))
|
||||
|
||||
(defmethod toc-clear ((object main-frame))
|
||||
(gui:listbox-delete (toc-listbox (toc-frame object))))
|
||||
|
||||
(defmethod (setf toc-char-width) (new-width (object main-frame))
|
||||
(gui:configure (gui:listbox (toc-listbox (toc-frame object))) :width new-width))
|
||||
|
||||
(defun print-info-message (message &key
|
||||
(color (gui-goodies:parse-color "black"))
|
||||
(bold nil))
|
||||
|
@ -1178,6 +1178,8 @@
|
||||
:+key-animation+
|
||||
:+key-x+
|
||||
:+key-y+
|
||||
:+key-maximum+
|
||||
:+key-minimum+
|
||||
:+key-error+
|
||||
:+key-info+
|
||||
:+key-window+
|
||||
@ -3266,7 +3268,8 @@
|
||||
:gemini-h2-justification
|
||||
:gemini-h3-justification
|
||||
:gemini-preformatted-text-justification
|
||||
:config-toc-width
|
||||
:config-toc-maximum-width
|
||||
:config-toc-minimum-width
|
||||
:toc-font-configuration))
|
||||
|
||||
(defpackage :client-os-utils
|
||||
|
@ -506,6 +506,8 @@
|
||||
animation
|
||||
x
|
||||
y
|
||||
maximum
|
||||
minimum
|
||||
error
|
||||
info
|
||||
window
|
||||
|
Loading…
Reference in New Issue
Block a user