• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Script Debugger 5: Duplicate Selection Handler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script Debugger 5: Duplicate Selection Handler


  • Subject: Re: Script Debugger 5: Duplicate Selection Handler
  • From: Shane Stanley <email@hidden>
  • Date: Wed, 12 Sep 2012 09:23:17 +1000

On 11/09/2012, at 3:32 PM, Christopher Stone <email@hidden> wrote:

Unfortunately the selection-object is not line-aware, so some other desirable things cannot be done such as select-line-of-selection


Not in a single line, perhaps, but it can certainly be done:

tell application "Script Debugger"
tell document 1
set {theLocation, theLength} to character range of selection
set theText to source text
set character range of selection to my paragraphRangeFor(theText, theLocation, theLength)
end tell
end tell

on paragraphRangeFor(theText, theLocation, theLength)
-- adjust for when last char of para is selected
if character (theLocation + theLength) of theText is in {return, linefeed} then set theLength to theLength - 1
-- get bits of paras before and after
set theBefore to paragraph -1 of text 1 through (theLocation - 1) of theText
set theAfter to paragraph 1 of text (theLocation + theLength + 1) through -1 of theText
-- build new selection range
set lastBeforeLength to length of theBefore
set newLocation to theLocation - lastBeforeLength
set newLength to lastBeforeLength + theLength + (length of theAfter) + 2
return {newLocation, newLength}
end paragraphRangeFor

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Script Debugger 5: Duplicate Selection Handler
      • From: Christopher Stone <email@hidden>
References: 
 >Script Debugger 5: Duplicate Selection Handler (From: Christopher Stone <email@hidden>)

  • Prev by Date: Use Spotlight to Archive Files
  • Next by Date: Re: Use Spotlight to Archive Files
  • Previous by thread: Re: Script Debugger 5: Duplicate Selection Handler
  • Next by thread: Re: Script Debugger 5: Duplicate Selection Handler
  • Index(es):
    • Date
    • Thread