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)))