Tuesday, September 21, 2021

#1 2021-09-15 08:31:37 am

peavine
Member
From:: Prescott, Arizona
Registered: 2018-09-04
Posts: 1043

Search and Highlight Matches in Script Debugger

Is there some method within Script Debugger to find and select or highlight every instance of a search string? If not, is there some way to do this with a script? The following works conceptually but I want all matching search strings to be selected or highlighted at one time. Thanks for the help.

Applescript:

set theSearchString to "search"

tell application "Script Debugger"
   set search wraps to true
   set search string to theSearchString
   tell document 1
       set startCharacterRange to character range of selection
       set firstCharacterRange to (search with action find first)
       set character range of selection to firstCharacterRange -- delete line
       delay 0.5 -- delete line
       -- select or highlight the search string -- add line
       repeat
           set nextCharacterRange to (search with action find next)
           if nextCharacterRange = firstCharacterRange then
               exit repeat
           else
               set character range of selection to nextCharacterRange -- delete line
               delay 0.5 -- delete line
               -- select or highlight the search string -- add line
           end if
       end repeat
       set character range of selection to startCharacterRange
   end tell
end tell

BTW, an easy solution would be to create a list of lists with each individual list being a character range, and then to have Script Debugger select the character ranges as in the following, but that appears not to be supported.

Applescript:

tell application "Script Debugger" to tell document 1
   set character range of selection to {{10,4} {20,8}}
end tell

Last edited by peavine (2021-09-15 08:47:17 am)


2018 Mac mini - macOS Catalina - Script Debugger 8

Offline

 

#2 2021-09-15 05:45:53 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6689

Re: Search and Highlight Matches in Script Debugger

Script Debugger doe not support more than one selection per text view.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)