1
1
on run -- for dialog
2
2
if existsWindow() then
3
- display dialog " Filter word" default answer "" buttons {" OK" } default button 1
4
- set userInput to text returned of result
3
+ display dialog " Filter word" default answer "" buttons {" and search" , " or search" , " search" } default button 3
4
+
5
+ set userInput to result
6
+
7
+ set userInputButton to button returned of userInput
8
+
9
+ set userInputText to text returned of userInput
10
+
11
+ if userInputButton is " search" then
12
+ set userInput to userInputText
13
+ else if userInputButton is " or search" then
14
+ set textList to makeList(userInputText, " " )
15
+ set userInput to ""
16
+ repeat with i from 1 to number of items in textList
17
+ set this_item to item i of textList
18
+ set userInput to userInput & " -e " & this_item & " "
19
+ end repeat
20
+ else if userInputButton is " and search" then
21
+ set userInput to replaceText(userInputText, " " , " | grep " )
22
+ end if
5
23
main(userInput)
6
24
end if
7
25
end run
@@ -68,3 +86,21 @@ on main(userInput)
68
86
69
87
end try
70
88
end main
89
+
90
+ on makeList (theText, theDelimiter ) -- テキストを指定語句で区切り配列に格納する
91
+ set tmp to AppleScript 's text item delimiters
92
+ set AppleScript 's text item delimiters to theDelimiter
93
+ set theList to every text item of theText
94
+ set AppleScript 's text item delimiters to tmp
95
+ return theList
96
+ end makeList
97
+
98
+ on replaceText (theText, serchStr, replaceStr )
99
+ set tmp to AppleScript 's text item delimiters
100
+ set AppleScript 's text item delimiters to serchStr
101
+ set theList to every text item of theText
102
+ set AppleScript 's text item delimiters to replaceStr
103
+ set theText to theList as string
104
+ set AppleScript 's text item delimiters to tmp
105
+ return theText
106
+ end replaceText
0 commit comments