Chris and JJ,

Thanks! I suspect it is time to really actually try to learn AppleScript. At 
the same time, I of course had forgotten that Unix Filters (now Text Filters) 
had access to useful BBEdit environment variables. With that I should be able 
to accomplish some of what I’d like to do in a language I am more comfortable 
with like Python. 

Thanks again!

On Mon, Aug 30, 2021, at 5:20 AM, Christopher Stone wrote:
> 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
>  
> <https://groups.google.com/d/msgid/bbedit/6F5238B6-5EF6-4674-9630-86B063A33BD5%40gmail.com?utm_medium=email&utm_source=footer>.

-- 
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/d551e34c-5834-4857-b08e-79ca36855284%40www.fastmail.com.

Reply via email to