AppleScript名:NSRangeの拡張、隣接検出 |
— Created 2018-1-12 by Takaaki Naganoya — 2018 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" –http://piyocast.com/as/archives/5118 set aRange to current application’s NSMakeRange(10, 80) –original range –> {location:10, |length|:80} set bRange to extendRange(aRange) of me –Extended range –> {location:9, |length|:81} set cRange to current application’s NSMakeRange(90, 30) –compare target range –> {location:90, |length|:30} set aRes to current application’s NSIntersectionRange(aRange, cRange) –> {location:0, |length|:0}–Not adjacent set bRes to current application’s NSIntersectionRange(bRange, cRange) –> {location:90, |length|:1}–Adjacent –NSRangeの開始点とサイズを拡張 on extendRange(aRange) set aLoc to location of aRange set aLen to |length| of aRange if aLoc > 0 then set aLoc to aLoc – 1 end if set aLen to aLen + 2 set bRange to current application’s NSMakeRange(aLoc, aLen) return bRange end extendRange |
More from my site
(Visited 117 times, 1 visits today)