From 6bdb23bf75b60e17e9d230301c386e4dffbbefc8 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 19 Dec 2007 04:12:10 +0000 Subject: [PATCH] added a message when the search is truncated svn: r8059 original commit: 3500ef305c1fa1dbc2547ab928ab6b4cdc6ce405 --- collects/help/search.ss | 45 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/collects/help/search.ss b/collects/help/search.ss index 2db94a3f..b6509226 100644 --- a/collects/help/search.ss +++ b/collects/help/search.ss @@ -115,33 +115,42 @@ search-regexps)) (entry-words entry))) +;; limit : exact-positive-integer +;; maximum number of hits to display +(define limit 500) + ;; build-itemization : (listof entry) -> (listof ) (define (build-itemization title entries) (cond [(null? entries) '()] [else - (list - (bold title) - (apply itemize - (map - (λ (entry) - (apply item - (make-link-element - "indexlink" - (entry-content entry) - (entry-tag entry)) - (make-extra-content - (entry-desc entry)))) - (limit-length - 500 - (sort - entries - (λ (x y) (string-ci<=? (entry->sort-key x) (entry->sort-key y))))))))])) + (let ([entries + (sort + entries + (λ (x y) (string-ci<=? (entry->sort-key x) (entry->sort-key y))))]) + (list* + (bold title) + (apply itemize + (map + (λ (entry) + (apply item + (make-link-element + "indexlink" + (entry-content entry) + (entry-tag entry)) + (make-extra-content + (entry-desc entry)))) + (limit-length + limit + entries))) + (if (<= (length entries) limit) + '() + (list (italic (format "Search truncated after ~a hits." limit))))))])) (define (limit-length n l) (cond - [(zero? n) '()] [(null? l) '()] + [(zero? n) '()] [else (cons (car l) (limit-length (- n 1) (cdr l)))])) (define (entry->sort-key e)