mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-17 08:10:36 +01:00
- [GUI] implemented TOC callback (scroll to header when clicking on
the corresponding TOC item.
This commit is contained in:
parent
2982dfdeeb
commit
910da66e4f
@ -126,7 +126,10 @@
|
||||
(loop for ct from 0
|
||||
for toc-item in toc do
|
||||
(gui:listbox-append (toc-listbox (toc-frame main-window))
|
||||
(getf toc-item :text))))))))
|
||||
(getf toc-item :text)))
|
||||
(setf (toc-data (toc-frame main-window))
|
||||
(loop for toc-item in toc collect (getf toc-item :header-group-id)))))
|
||||
main-window)))
|
||||
|
||||
(defun slurp-gemini-stream (main-window iri stream-wrapper &key
|
||||
(use-cache t)
|
||||
@ -651,21 +654,45 @@
|
||||
(gui-mw::hide-candidates iri-entry)
|
||||
(open-iri iri main-window use-cache))))))
|
||||
|
||||
(defun toc-callback-clsr (main-window)
|
||||
(with-accessors ((toc-frame toc-frame)
|
||||
(gemtext-widget gemtext-widget)
|
||||
(ir-lines ir-lines)) main-window
|
||||
(let ((toc-listbox (gui:listbox (toc-listbox toc-frame))))
|
||||
(lambda (event)
|
||||
(declare (ignore event))
|
||||
(a:when-let* ((index-item (first (gui:listbox-get-selection-index toc-listbox)))
|
||||
(selected-group-id (elt (toc-data toc-frame) index-item))
|
||||
(line-position (position-if (lambda (a)
|
||||
(a:when-let ((gid (getf a
|
||||
:header-group-id)))
|
||||
(= selected-group-id gid)))
|
||||
ir-lines))
|
||||
(line-index (1+ line-position)))
|
||||
(gui:scroll-until-line-on-top gemtext-widget line-index))))))
|
||||
|
||||
(defun setup-main-window-events (main-window)
|
||||
(with-accessors ((tool-bar tool-bar)) main-window
|
||||
(with-accessors ((tool-bar tool-bar)
|
||||
(toc-frame toc-frame)
|
||||
(gemtext-widget gemtext-widget)
|
||||
(ir-lines ir-lines)) main-window
|
||||
(with-accessors ((iri-entry iri-entry)
|
||||
(back-button back-button)
|
||||
(reload-button reload-button)
|
||||
(up-button up-button)
|
||||
(go-button go-button)) tool-bar
|
||||
(let ((entry-autocomplete (gui-mw:autocomplete-entry-widget iri-entry)))
|
||||
(let ((entry-autocomplete (gui-mw:autocomplete-entry-widget iri-entry))
|
||||
(toc-listbox (gui:listbox (toc-listbox toc-frame))))
|
||||
(gui:bind entry-autocomplete
|
||||
#$<KeyPress-Return>$
|
||||
(lambda (e)
|
||||
(declare (ignore e))
|
||||
(funcall (open-iri-clsr main-window t)))
|
||||
:append nil))
|
||||
(setf (gui:command go-button) (open-iri-clsr main-window t)))))
|
||||
:append nil)
|
||||
(gui:bind toc-listbox
|
||||
#$<<ListboxSelect>>$
|
||||
(toc-callback-clsr main-window))
|
||||
(setf (gui:command go-button) (open-iri-clsr main-window t))))))
|
||||
|
||||
(defmethod initialize-instance :after ((object tool-bar) &key &allow-other-keys)
|
||||
(with-accessors ((iri-entry iri-entry)
|
||||
|
Loading…
x
Reference in New Issue
Block a user