mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-07 03:00:49 -08:00
regex for filenames
This commit is contained in:
parent
8ebc9e1ec9
commit
8647c998ca
3 changed files with 70 additions and 54 deletions
|
|
@ -19,12 +19,15 @@
|
||||||
(declare (ignore target))
|
(declare (ignore target))
|
||||||
(destroy-children (result-box panel))
|
(destroy-children (result-box panel))
|
||||||
(let* ((subdirs (checkedp (subdir-check panel)))
|
(let* ((subdirs (checkedp (subdir-check panel)))
|
||||||
|
(nregex (text-value (name-regex-input panel)))
|
||||||
|
(sn (ppcre:create-scanner nregex :case-insensitive-mode t))
|
||||||
(regex (text-value (grep-input panel)))
|
(regex (text-value (grep-input panel)))
|
||||||
(s (ppcre:create-scanner regex :case-insensitive-mode t)))
|
(s (ppcre:create-scanner regex :case-insensitive-mode t)))
|
||||||
(labels ((do-search (dir prefix)
|
(labels ((do-search (dir prefix)
|
||||||
(dolist (item (uiop:directory-files dir))
|
(dolist (item (uiop:directory-files dir))
|
||||||
(let* ((fname (format nil "~A" item))
|
(let ((fname (format nil "~A" item)))
|
||||||
(c (read-file fname :report-errors nil)))
|
(when (ppcre:scan sn fname)
|
||||||
|
(let ((c (read-file fname :report-errors nil)))
|
||||||
(when (and c
|
(when (and c
|
||||||
(ppcre:scan s c))
|
(ppcre:scan s c))
|
||||||
(let ((li (create-option (result-box panel)
|
(let ((li (create-option (result-box panel)
|
||||||
|
|
@ -35,7 +38,7 @@
|
||||||
:regex regex)))
|
:regex regex)))
|
||||||
(set-on-double-click li (lambda (obj)
|
(set-on-double-click li (lambda (obj)
|
||||||
(declare (ignore obj))
|
(declare (ignore obj))
|
||||||
(do-select))))))))
|
(do-select))))))))))
|
||||||
(when subdirs
|
(when subdirs
|
||||||
(dolist (item (uiop:subdirectories dir))
|
(dolist (item (uiop:subdirectories dir))
|
||||||
(do-search item (format nil "~A~A/" prefix (first (last (pathname-directory item)))))))))
|
(do-search item (format nil "~A~A/" prefix (first (last (pathname-directory item)))))))))
|
||||||
|
|
|
||||||
34
tools/panel-search.clog
vendored
34
tools/panel-search.clog
vendored
|
|
@ -1,31 +1,35 @@
|
||||||
<data id="I3929129042" data-in-package="clog-tools" data-custom-slots=""
|
<data id="I3929200389" data-in-package="clog-tools" data-custom-slots=""
|
||||||
data-clog-next-id="8" data-clog-title="panel-search"></data>
|
data-clog-next-id="9" data-clog-title="panel-search"></data>
|
||||||
<form action="#" onsubmit="return false;" data-clog-name="search-form"
|
<form action="#" onsubmit="return false;" data-clog-name="search-form"
|
||||||
data-clog-type="form">
|
data-clog-type="form">
|
||||||
<div data-clog-type="grid" data-clog-name="result-grid"
|
<div data-clog-type="grid" data-clog-name="result-grid"
|
||||||
style="display: grid; box-sizing: content-box; position: absolute; inset: 5px; gap: 5px; grid-template: "a a a a" 1fr "d d d d" 28px "b o l c" 28px / 1fr 20px 70px 80px;"
|
style="display: grid; box-sizing: content-box; position: absolute; inset: 5px; gap: 5px; grid-template: "a a a a a" 1fr "d d d d d" 28px "b n o l c" 28px / 1fr 100px 20px 70px 80px;"
|
||||||
class=""><select data-clog-type="listbox" size="4"
|
class=""><select data-clog-type="listbox" size="4"
|
||||||
data-clog-name="result-box"
|
data-clog-name="result-box"
|
||||||
style="box-sizing: content-box; position: static; grid-area: a;"
|
style="box-sizing: content-box; position: static; grid-area: a;"
|
||||||
class="w3-small" tabindex="2"></select><input type="TEXT" value=""
|
class="w3-small" tabindex="1"></select><input type="TEXT" value=""
|
||||||
data-clog-type="input" data-clog-name="dir-input"
|
data-clog-type="input" data-clog-name="dir-input"
|
||||||
style="box-sizing: content-box; position: static; grid-area: d;"
|
style="box-sizing: content-box; position: static; grid-area: d;"
|
||||||
data-on-change="(panel-search-dir-change panel target)"
|
data-on-change="(panel-search-dir-change panel target)"
|
||||||
placeholder="directory to search" tabindex="3"><input type="TEXT"
|
placeholder="directory to search" tabindex="2"><input type="TEXT"
|
||||||
value="" data-clog-type="input" data-clog-name="grep-input"
|
value="" data-clog-type="input" data-clog-name="grep-input"
|
||||||
style="box-sizing: content-box; position: static; left: 50px; top: 8px; grid-area: b;"
|
style="box-sizing: content-box; position: static; left: 50px; top: 8px; grid-area: b;"
|
||||||
placeholder="search regex" tabindex="4" data-on-create="(setf (attribute target "autofocus") "true")
|
placeholder="search regex" tabindex="3" data-on-create="(setf (attribute target "autofocus") "true")
|
||||||
(focus target)">
|
(focus target)">
|
||||||
<input type="CHECKBOX" value="" data-clog-type="checkbox"
|
<input type="TEXT" value="(.*\\.lisp$)" data-clog-type="input"
|
||||||
data-clog-name="subdir-check"
|
data-clog-name="name-regex-input"
|
||||||
style="box-sizing: content-box; position: static; left: 68px; top: 5px; grid-area: o;"><label
|
style="box-sizing: content-box; position: static; left: 43px; top: 11px; grid-area: n;"
|
||||||
for="undefined" data-clog-type="label" data-clog-for="sundir-check"
|
placeholder="file regex" tabindex="4"><input type="CHECKBOX"
|
||||||
|
value="" data-clog-type="checkbox" data-clog-name="subdir-check"
|
||||||
|
style="box-sizing: content-box; position: static; left: 68px; top: 5px; grid-area: o;"
|
||||||
|
tabindex="5" checked="checked"><label for="CLOGB3929199716"
|
||||||
|
data-clog-type="label" data-clog-for="subdir-check"
|
||||||
data-clog-name="subdir-label"
|
data-clog-name="subdir-label"
|
||||||
style="box-sizing: content-box; position: static; left: 70px; top: 11px; grid-area: l;"
|
style="box-sizing: content-box; position: static; left: 70px; top: 11px; grid-area: l; font: 15px / 22.5px sans-serif; visibility: visible; vertical-align: middle; text-align: center;"
|
||||||
class="">sub dirs</label><input type="submit" value="Search"
|
class="w3-tiny">subdirectories</label><input type="submit"
|
||||||
data-clog-type="input" data-clog-name="search-button"
|
value="Search" data-clog-type="input" data-clog-name="search-button"
|
||||||
style="box-sizing: content-box; position: static; height: 22px; grid-area: c;"
|
style="box-sizing: content-box; position: static; height: 22px; grid-area: c;"
|
||||||
data-on-click="(panel-search-on-click panel target)" class=""
|
class="" tabindex="6"
|
||||||
tabindex="1">
|
data-on-click="(panel-search-on-click panel target)">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -3,37 +3,43 @@
|
||||||
(defclass panel-search (clog:clog-panel)
|
(defclass panel-search (clog:clog-panel)
|
||||||
((search-button :reader search-button)
|
((search-button :reader search-button)
|
||||||
(subdir-label :reader subdir-label)
|
(subdir-label :reader subdir-label)
|
||||||
(subdir-check :reader subdir-check) (grep-input :reader grep-input)
|
(subdir-check :reader subdir-check)
|
||||||
(dir-input :reader dir-input) (result-box :reader result-box)
|
(name-regex-input :reader name-regex-input)
|
||||||
(result-grid :reader result-grid) (search-form :reader search-form)))
|
(grep-input :reader grep-input) (dir-input :reader dir-input)
|
||||||
|
(result-box :reader result-box) (result-grid :reader result-grid)
|
||||||
|
(search-form :reader search-form)))
|
||||||
(defun create-panel-search
|
(defun create-panel-search
|
||||||
(clog-obj &key hidden class style html-id (auto-place t))
|
(clog-obj &key hidden class style html-id (auto-place t))
|
||||||
(let ((panel
|
(let ((panel
|
||||||
(change-class
|
(change-class
|
||||||
(clog:create-div clog-obj :content
|
(clog:create-div clog-obj :content
|
||||||
"<form action=\"#\" onsubmit=\"return false;\" id=\"CLOGB3929127594\"
|
"<form action=\"#\" onsubmit=\"return false;\" id=\"CLOGB3929199710\"
|
||||||
data-clog-name=\"search-form\">
|
data-clog-name=\"search-form\">
|
||||||
<div style=\"display: grid; box-sizing: content-box; position: absolute; inset: 5px; gap: 5px; grid-template: "a a a a" 1fr "d d d d" 28px "b o l c" 28px / 1fr 20px 70px 80px;\"
|
<div style=\"display: grid; box-sizing: content-box; position: absolute; inset: 5px; gap: 5px; grid-template: "a a a a a" 1fr "d d d d d" 28px "b n o l c" 28px / 1fr 100px 20px 70px 80px;\"
|
||||||
class=\"\" id=\"CLOGB3929127595\" data-clog-name=\"result-grid\"><select
|
class=\"\" id=\"CLOGB3929199711\" data-clog-name=\"result-grid\"><select
|
||||||
size=\"4\"
|
size=\"4\"
|
||||||
style=\"box-sizing: content-box; position: static; grid-area: a;\"
|
style=\"box-sizing: content-box; position: static; grid-area: a;\"
|
||||||
class=\"w3-small\" tabindex=\"2\" id=\"CLOGB3929127596\"
|
class=\"w3-small\" tabindex=\"1\" id=\"CLOGB3929199712\"
|
||||||
data-clog-name=\"result-box\"></select><input type=\"TEXT\" value=\"\"
|
data-clog-name=\"result-box\"></select><input type=\"TEXT\" value=\"\"
|
||||||
style=\"box-sizing: content-box; position: static; grid-area: d;\"
|
style=\"box-sizing: content-box; position: static; grid-area: d;\"
|
||||||
placeholder=\"directory to search\" tabindex=\"3\" id=\"CLOGB3929127597\"
|
placeholder=\"directory to search\" tabindex=\"2\" id=\"CLOGB3929199713\"
|
||||||
data-clog-name=\"dir-input\"><input type=\"TEXT\" value=\"\"
|
data-clog-name=\"dir-input\"><input type=\"TEXT\" value=\"\"
|
||||||
style=\"box-sizing: content-box; position: static; left: 50px; top: 8px; grid-area: b;\"
|
style=\"box-sizing: content-box; position: static; left: 50px; top: 8px; grid-area: b;\"
|
||||||
placeholder=\"search regex\" tabindex=\"4\" id=\"CLOGB3929127598\"
|
placeholder=\"search regex\" tabindex=\"3\" id=\"CLOGB3929199714\"
|
||||||
data-clog-name=\"grep-input\">
|
data-clog-name=\"grep-input\">
|
||||||
<input type=\"CHECKBOX\" value=\"\" id=\"CLOGB39291277016\"
|
<input type=\"TEXT\" value=\"(.*\\.lisp$)\"
|
||||||
|
style=\"box-sizing: content-box; position: static; left: 43px; top: 11px; grid-area: n;\"
|
||||||
|
placeholder=\"file regex\" id=\"CLOGB3929199715\" tabindex=\"4\"
|
||||||
|
data-clog-name=\"name-regex-input\"><input type=\"CHECKBOX\" value=\"\"
|
||||||
style=\"box-sizing: content-box; position: static; left: 68px; top: 5px; grid-area: o;\"
|
style=\"box-sizing: content-box; position: static; left: 68px; top: 5px; grid-area: o;\"
|
||||||
data-clog-name=\"subdir-check\"><label for=\"undefined\"
|
id=\"CLOGB3929199716\" tabindex=\"5\" checked=\"checked\"
|
||||||
id=\"CLOGB39291277397\"
|
data-clog-name=\"subdir-check\"><label for=\"CLOGB3929199716\"
|
||||||
style=\"box-sizing: content-box; position: static; left: 70px; top: 11px; grid-area: l;\"
|
style=\"box-sizing: content-box; position: static; left: 70px; top: 11px; grid-area: l; font: 15px / 22.5px sans-serif; visibility: visible; vertical-align: middle; text-align: center;\"
|
||||||
class=\"\" data-clog-name=\"subdir-label\">sub dirs</label><input
|
class=\"w3-tiny\" id=\"CLOGB3929199717\"
|
||||||
|
data-clog-name=\"subdir-label\">subdirectories</label><input
|
||||||
type=\"submit\" value=\"Search\"
|
type=\"submit\" value=\"Search\"
|
||||||
style=\"box-sizing: content-box; position: static; height: 22px; grid-area: c;\"
|
style=\"box-sizing: content-box; position: static; height: 22px; grid-area: c;\"
|
||||||
class=\"\" tabindex=\"1\" id=\"CLOGB3929127599\"
|
class=\"\" tabindex=\"6\" id=\"CLOGB3929199718\"
|
||||||
data-clog-name=\"search-button\">
|
data-clog-name=\"search-button\">
|
||||||
</div>
|
</div>
|
||||||
</form>"
|
</form>"
|
||||||
|
|
@ -41,28 +47,31 @@
|
||||||
html-id :auto-place auto-place)
|
html-id :auto-place auto-place)
|
||||||
'panel-search)))
|
'panel-search)))
|
||||||
(setf (slot-value panel 'search-button)
|
(setf (slot-value panel 'search-button)
|
||||||
(attach-as-child clog-obj "CLOGB3929127599" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199718" :clog-type
|
||||||
'clog:clog-form-element :new-id t))
|
'clog:clog-form-element :new-id t))
|
||||||
(setf (slot-value panel 'subdir-label)
|
(setf (slot-value panel 'subdir-label)
|
||||||
(attach-as-child clog-obj "CLOGB39291277397" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199717" :clog-type
|
||||||
'clog:clog-label :new-id t))
|
'clog:clog-label :new-id t))
|
||||||
(setf (slot-value panel 'subdir-check)
|
(setf (slot-value panel 'subdir-check)
|
||||||
(attach-as-child clog-obj "CLOGB39291277016" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199716" :clog-type
|
||||||
|
'clog:clog-form-element :new-id t))
|
||||||
|
(setf (slot-value panel 'name-regex-input)
|
||||||
|
(attach-as-child clog-obj "CLOGB3929199715" :clog-type
|
||||||
'clog:clog-form-element :new-id t))
|
'clog:clog-form-element :new-id t))
|
||||||
(setf (slot-value panel 'grep-input)
|
(setf (slot-value panel 'grep-input)
|
||||||
(attach-as-child clog-obj "CLOGB3929127598" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199714" :clog-type
|
||||||
'clog:clog-form-element :new-id t))
|
'clog:clog-form-element :new-id t))
|
||||||
(setf (slot-value panel 'dir-input)
|
(setf (slot-value panel 'dir-input)
|
||||||
(attach-as-child clog-obj "CLOGB3929127597" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199713" :clog-type
|
||||||
'clog:clog-form-element :new-id t))
|
'clog:clog-form-element :new-id t))
|
||||||
(setf (slot-value panel 'result-box)
|
(setf (slot-value panel 'result-box)
|
||||||
(attach-as-child clog-obj "CLOGB3929127596" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199712" :clog-type
|
||||||
'clog:clog-select :new-id t))
|
'clog:clog-select :new-id t))
|
||||||
(setf (slot-value panel 'result-grid)
|
(setf (slot-value panel 'result-grid)
|
||||||
(attach-as-child clog-obj "CLOGB3929127595" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199711" :clog-type
|
||||||
'clog:clog-div :new-id t))
|
'clog:clog-div :new-id t))
|
||||||
(setf (slot-value panel 'search-form)
|
(setf (slot-value panel 'search-form)
|
||||||
(attach-as-child clog-obj "CLOGB3929127594" :clog-type
|
(attach-as-child clog-obj "CLOGB3929199710" :clog-type
|
||||||
'clog:clog-form :new-id t))
|
'clog:clog-form :new-id t))
|
||||||
(let ((target (grep-input panel)))
|
(let ((target (grep-input panel)))
|
||||||
(declare (ignorable target))
|
(declare (ignorable target))
|
||||||
|
|
@ -72,7 +81,7 @@
|
||||||
(declare (ignorable target))
|
(declare (ignorable target))
|
||||||
(setf (attribute target "for")
|
(setf (attribute target "for")
|
||||||
(clog:js-query target
|
(clog:js-query target
|
||||||
"$('[data-clog-name=\\'sundir-check\\']').attr('id')")))
|
"$('[data-clog-name=\\'subdir-check\\']').attr('id')")))
|
||||||
(clog:set-on-change (dir-input panel)
|
(clog:set-on-change (dir-input panel)
|
||||||
(lambda (target)
|
(lambda (target)
|
||||||
(declare (ignorable target))
|
(declare (ignorable target))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue