1
0
mirror of https://codeberg.org/cage/tinmop/ synced 2024-12-18 23:22:52 +01:00

- [GUI] improved gemtext search interface.

This commit is contained in:
cage 2024-12-13 14:41:27 +01:00
parent 38ce6cfe91
commit ea00615a3e

View File

@ -65,20 +65,28 @@
(gui-goodies:attach-tooltips ((button-next frame) (_ "make next match visible"))
((button-previous frame) (_ "make previous match visible"))
(button-close (_ "end searching")))
(gui:bind (entry frame)
#$<KeyPress-Return>$
(start-search-clsr frame
gemtext-widget
(not (gui:value case-sensitive-checkbox))))
(setf (gui:command (button-next frame))
(lambda ()
(when (matches frame)
(setf (counter frame) (rem (1+ (counter frame)) (length (matches frame))))
(gui:see gemtext-widget (gui:match-start (elt (matches frame) (counter frame)))))))
(setf (gui:command (button-previous frame))
(lambda ()
(when (matches frame)
(setf (counter frame) (max 0 (1- (counter frame))))
(gui:see gemtext-widget (gui:match-start (elt (matches frame) (counter frame)))))))
(setf (gui:command button-close) (lambda () (gui:grid-forget frame)))
frame))
(flet ((move-to-search-results (counter-add-function)
(if (matches frame)
(progn
(setf (counter frame) (rem (funcall counter-add-function
(counter frame))
(length (matches frame))))
(gui:see gemtext-widget (gui:match-start (elt (matches frame)
(counter frame)))))
(client-main-window:print-info-message (format nil
(_ "No occurrences of ~s found")
(gui:text (entry frame)))))))
(gui:bind (entry frame)
#$<KeyPress-Return>$
(lambda (e)
(funcall (start-search-clsr frame
gemtext-widget
(not (gui:value case-sensitive-checkbox)))
e)
(move-to-search-results #'1+)))
(setf (gui:command (button-next frame))
(lambda () (move-to-search-results #'1+)))
(setf (gui:command (button-previous frame))
(lambda () (move-to-search-results #'1-)))
(setf (gui:command button-close) (lambda () (gui:grid-forget frame)))
frame)))