On Aug 29, 2021, at 21:12, Tim Gray <[email protected]> wrote:
> Is AppleScript the best/most powerful way to script text manipulation based 
> on where the cursor currently is?

Hey Tim,

Basically.  Although as JJ mentions environment variables offer a good deal of 
information to shell scripts, it's more complicated to use that information in 
the shell than with AppleScript.

Here's your basic AppleScript for the task:

--------------------------------------------------------
# Auth: Christopher Stone <[email protected]>
# dCre: 2021/08/30 04:02
# dMod: 2021/08/30 04:02 
# Appl: BBEdit
# Task: Working with the selection in the front text window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Selection, @Text, @Window
--------------------------------------------------------

tell application "BBEdit"
    tell front text window
        
        --» Acquire relevant information about the selection.
        tell selection
            set selectionLength to its length
            set start_Line to its startLine
            set end_Line to its endLine
        end tell
        
        --» Process the selection.
        if selectionLength = 0 or start_Line = end_Line then
            # Process line start_Line.
        else
            # Process lines start_Line through end_Line.
        end if
        
    end tell
end tell

--------------------------------------------------------

Let us know if you need any more help.


--
Best Regards,
Chris


-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/6F5238B6-5EF6-4674-9630-86B063A33BD5%40gmail.com.

Reply via email to