<commit_before>#lang racket/unit
  (require framework
           mzlib/class
           mred
           racket/file
           racket/path
           mzlib/thread
           mzlib/async-channel
           string-constants
           "drsig.rkt")
  
  (import [prefix drracket:frame: drracket:frame^]
          [prefix drracket:unit: drracket:unit^]
          [prefix drracket: drracket:interface^])
  (export drracket:multi-file-search^)
  
  ;; multi-file-search : -> void
  ;; opens a dialog to configure the search and initiates the search
  (define (multi-file-search)
    (let ([search-info  (configure-search)])
      (when search-info
        (open-search-window search-info))))
  
  ;; searcher = (string (string int int int -> void) -> void)
  ;; this performs a single search.
  ;; the first argument is the filename to be searched
  ;; the second argument is called for each match.
  ;;     the arguments are: line-string line-number col-number match-length
  
  
  ;; search-type = (make-search-type string make-searcher (listof (cons string boolean)))
  ;; the param strings are the labels for checkboxes
  ;; the param booleans are the default values for the checkboxes
  ;; these are the available searches
  (define-struct search-type (label make-searcher params))
  
  ;; search-info = (make-search-info string boolean (union #f regexp) search-type string)
  ;; the search-string field is only informative; not used for actual searching
  (define-struct search-info (dir recur? filter searcher search-string))
  
  ;; search-types : (listof search-type)
  (define search-types
    (list (make-search-type
           (string-constant mfs-string-match/graphics)
           (λ (info search-string) (exact-match-searcher info search-string))
           (list (cons (string-constant mfs-case-sensitive-label) #f)))
          (make-search-type
           (string-constant mfs-regexp-match/no-graphics)
           (λ (info search-string) (regexp-match-searcher info search-string))
           (list))))
  
  ;; search-entry = (make-search-entry string number number number)
  (define-struct search-entry (filename line-string line-number col-number match-length))
  
  ;; open-search-window : search-info -> void
  ;; thread: eventspace main thread
  ;; opens a window and creates the thread that does the search
  (define (open-search-window search-info)
    (define frame (new search-size-frame%
                       [name (format (string-constant mfs-drscheme-multi-file-search-title)
                                      (search-info-search-string search-info))]))
    (define panel (make-object saved-vertical-resizable% (send frame get-area-container)))
    (define button-panel (make-object horizontal-panel% (send frame get-area-container)))
    (define open-button (make-object button% (string-constant mfs-open-file) button-panel
                          (λ (x y) (open-file-callback))))
    (define stop-button (make-object button% (string-constant mfs-stop-search) button-panel
                          (λ (x y) (stop-callback))))
    (define grow-box-pane (make-object grow-box-spacer-pane% button-panel))
    
    (define zoom-text (make-object racket:text%))
    (define results-text (make-object results-text% zoom-text))
    (define results-ec (instantiate searching-canvas% ()
                         (parent panel)
                         (editor results-text)
                         (frame frame)))
    (define zoom-ec (instantiate searching-canvas% ()
                      (parent panel)
                      (editor zoom-text)
                      (frame frame)))
    
    (define (open-file-callback)<commit_msg>account for long search strings when opening the results window in "search in files"<commit_after>#lang racket/unit
  (require framework
           mzlib/class
           mred
           racket/file
           racket/path
           mzlib/thread
           mzlib/async-channel
           string-constants
           "drsig.rkt")
  
  (import [prefix drracket:frame: drracket:frame^]
          [prefix drracket:unit: drracket:unit^]
          [prefix drracket: drracket:interface^])
  (export drracket:multi-file-search^)
  
  ;; multi-file-search : -> void
  ;; opens a dialog to configure the search and initiates the search
  (define (multi-file-search)
    (let ([search-info  (configure-search)])
      (when search-info
        (open-search-window search-info))))
  
  ;; searcher = (string (string int int int -> void) -> void)
  ;; this performs a single search.
  ;; the first argument is the filename to be searched
  ;; the second argument is called for each match.
  ;;     the arguments are: line-string line-number col-number match-length
  
  
  ;; search-type = (make-search-type string make-searcher (listof (cons string boolean)))
  ;; the param strings are the labels for checkboxes
  ;; the param booleans are the default values for the checkboxes
  ;; these are the available searches
  (define-struct search-type (label make-searcher params))
  
  ;; search-info = (make-search-info string boolean (union #f regexp) search-type string)
  ;; the search-string field is only informative; not used for actual searching
  (define-struct search-info (dir recur? filter searcher search-string))
  
  ;; search-types : (listof search-type)
  (define search-types
    (list (make-search-type
           (string-constant mfs-string-match/graphics)
           (λ (info search-string) (exact-match-searcher info search-string))
           (list (cons (string-constant mfs-case-sensitive-label) #f)))
          (make-search-type
           (string-constant mfs-regexp-match/no-graphics)
           (λ (info search-string) (regexp-match-searcher info search-string))
           (list))))
  
  ;; search-entry = (make-search-entry string number number number)
  (define-struct search-entry (filename line-string line-number col-number match-length))
  
  ;; open-search-window : search-info -> void
  ;; thread: eventspace main thread
  ;; opens a window and creates the thread that does the search
  (define (open-search-window search-info)
    (define frame (new search-size-frame%
                       [name 
                        (let ([fmt-s (string-constant mfs-drscheme-multi-file-search-title)])
                          (format 
                           fmt-s
                           (gui-utils:trim-string (search-info-search-string search-info)
                                                  (- 200 (string-length fmt-s)))))]))
    (define panel (make-object saved-vertical-resizable% (send frame get-area-container)))
    (define button-panel (make-object horizontal-panel% (send frame get-area-container)))
    (define open-button (make-object button% (string-constant mfs-open-file) button-panel
                          (λ (x y) (open-file-callback))))
    (define stop-button (make-object button% (string-constant mfs-stop-search) button-panel
                          (λ (x y) (stop-callback))))
    (define grow-box-pane (make-object grow-box-spacer-pane% button-panel))
    
    (define zoom-text (make-object racket:text%))
    (define results-text (make-object results-text% zoom-text))
    (define results-ec (instantiate searching-canvas% ()
                         (parent panel)
                         (editor results-text)
                         (frame frame)))
    (define zoom-ec (instantiate searching-canvas% ()
                      (parent panel)
                      (editor zoom-text)
                      (frame frame)))
    
    (define (open-file-callback)
{'fraction_non_alphanumeric': 0.11109645071909223, 'fraction_numerical': 0.0003958305845098298, 'mean_word_length': 2.3172866520787747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3862777', 'n_tokens_mistral': 2154, 'n_tokens_neox': 2090, 'n_words': 603}