From ea00615a3ec1e4e484fd583e96c83b61eeafcacd Mon Sep 17 00:00:00 2001 From: cage Date: Fri, 13 Dec 2024 14:41:27 +0100 Subject: [PATCH] - [GUI] improved gemtext search interface. --- src/gui/client/search-frame.lisp | 42 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/gui/client/search-frame.lisp b/src/gui/client/search-frame.lisp index 36f6be2..f39ab22 100644 --- a/src/gui/client/search-frame.lisp +++ b/src/gui/client/search-frame.lisp @@ -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) - #$$ - (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) + #$$ + (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)))