On Tuesday, August 21, 2012 9:45:30 AM UTC-3, Christopher Stone wrote:
>
> Hey Pierre,
>
> It looks to me like you've exposed a bug. I've got a query in to support,
> so we'll see.
>
> In the meantime this rather quick and dirty script works.
>
>
> ------------------------------------------------------------------------------------------------
> try
>
>
> tell *application* "BBEdit"
> tell *text* of front *text window*
> set endMarker to (characterOffset of selection) + (length of
> selection) - 1
> set fRec to *find* "[^\\r]+" options {search mode:grep, starting at
> top:false, wrap around:false, backwards:true, case sensitive:false, match
> words:false, extend selection:true} with selecting match
> set foundObject to found object of fRec
> properties of foundObject
> set startmarker to characterOffset of foundObject
> *select* (*characters* startmarker thru endMarker)
> end tell
> end tell
>
>
> on error eMsg number eNum
> set {c, s} to {return, "------------------------------------------"}
> set e to s & c & "Error: " & eMsg & c & s & c & "Error Number: " & eNum&
> c & s
> *beep*
> set dDlg to *display dialog* e buttons {"Cancel", "Copy", "OK"} default
> button "OK"
> if button returned of dDlg = "Copy" then
> *set the clipboard to* e
> end if
> end try
>
> ------------------------------------------------------------------------------------------------
>
>
Hi Chris,
Thanks a lot for the reply. It looks like it works for extending upwards.
An added bonus is that it also works all the way to the very beginning of
the document, whereas the other script could not extend the selection to
include the very first paragraph, since it is not preceded by a paragraph
mark.
Similarly, the existing script that I have for extending the selection
backwards works, but also fails at the very last paragraph of the document,
for similar reasons.
I've adapted your script to work the other way too:
---
*tell* *application* "BBEdit"
*tell* *text* *of* *front* *text window*
*set* startmarker *to* (characterOffset *of* selection)
*set* fRec *to* *find* "\\r" options {search mode:grep, starting at top:
false, wrap around:false, backwards:false, case sensitive:false, match words
:false, extend selection:true} *with* selecting match
*set* foundObject *to* found object *of* fRec
properties *of* foundObject
*set* endMarker *to* (characterOffset *of* foundObject) + (length *of*
foundObject)
*select* (*characters* startmarker *thru* endMarker)
*end* *tell*
*end* *tell*
*--*
*
*
It seems to be working, but I'd appreciate it if you could have a quick
look and let me know if there's anything that I've misunderstood or that
might need to be adjusted.
Thanks!
Pierre
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>