REBOL [ title: "Multi-File Search" author: "Henrik Mikael Kristensen" ] results: copy [] over-color: 200.200.255 over-count: none cnt: 0 search-function: func [/local files] [ results: copy [] show status files: read to-file get-face t-dir remove-each i files [dir? i] nof-files: length? files forall files [ if not dir? first files [ data: read/lines first files status/text: join "Searching: " first files set-face f-progress divide index? files nof-files show [status f-progress] forall data [ if found? either get-face c-case [ find/any/case first data get-face t-search ][ find/any first data get-face t-search ][ insert/only tail results reduce [ first files index? data trim first data ] ] ] ] ] status/text: reform ["Results:" length? results "found"] update-lst show [results-list status] ] update-lst: does [ cnt: 0 scr/data: 0 scr/redrag lst-cnt / max 1 length? results show [scr results-list] ] main: layout [ style header button 100x20 gray edge [size: 1x1] style hdr txt bold white black 20x20 bd: backdrop effect [gradient 0x1 200.200.200 180.180.180] across space 2 origin 8 text "Search Multiple Files" bold return search-pnl: panel [ across space 2 t-search: field (as-pair 268 22) f-search: btn 70 "Search" [ if not empty? t-search/text [search-function] ] return t-dir: field (as-pair 268 22) f-dir: btn 70 "Directory..." [ set-face t-dir request-dir ] ] return flags-pnl: panel [ origin 2 across space 2 text "Recursive" c-recursive: check pad 8 text "Case Sensitive" c-case: check ] return status: text 340x20 "Results" bold return space 0x0 h-file: hdr 120 "File" h-line: hdr 50 "Line" h-text: hdr 152 "Text" box black 18x20 return results-list: list 340x300 - 16x0 [ across space 0 style txt base-text font [colors: [0.0.0 0.0.0]] txt 120 txt 50 txt 1024 ] supply [ count: count + cnt face/color: pick [240.240.240 220.230.220] odd? count face/text: "" if over-count = count [face/color: over-color] face/data: count face/text: attempt [results/:count/:index] ] do [lst-cnt: to-integer results-list/size/y / results-list/subface/size/y - 1] scr: scroller 16x300 [ value: to-integer value * max 0 (length? results) - lst-cnt if cnt <> value [cnt: value show results-list] ] return do [update-lst] f-progress: progress gray white 340x10 return space 2 btn-pnl: panel [ origin 0x2 across space 2 btn "OK" [results] btn "Cancel" [unview main] ] ] on-resize: has [fp] [ spacing: 2 offset: 8 bd/size: main/size search-pnl/size/x: main/size/x - (search-pnl/offset/x * 2) f-dir/offset/x: f-search/offset/x: search-pnl/size/x - f-search/size/x t-dir/size/x: t-search/size/x: search-pnl/size/x - f-search/size/x - 2 btn-pnl/offset/y: main/size/y - btn-pnl/size/y - offset results-list/size/x: search-pnl/size/x - scr/size/x results-list/size/y: btn-pnl/offset/y - results-list/offset/y - f-progress/size/y f-progress/size/x: search-pnl/size/x f-progress/offset/y: results-list/size/y + results-list/offset/y fp: get-face f-progress set-face f-progress 0 set-face f-progress fp scr/offset/x: search-pnl/size/x + search-pnl/offset/x - scr/size/x scr/resize/y results-list/size/y lst-cnt: to-integer results-list/size/y / results-list/subface/size/y - 1 scr/redrag lst-cnt / max 1 length? results h-text/size/x: search-pnl/size/x - h-text/offset/x + offset show main ] set-face f-dir %. insert-event-func [ if event/type = 'resize [on-resize] event ] view/options center-face main 'resize