Re: Set selection point to next line in AppleScript

2021-08-05 Thread Rainer Krug
Replied to fast. 

I changed `startLine *of* selection` to `endLine *of* selection` and now it 
moves to the next line after the selection.

Thanks,

Rainer


On Thursday, August 5, 2021 at 1:27:40 PM UTC+2 Rainer Krug wrote:

> Perfect. Thanks.
>
>
> On Thursday, August 5, 2021 at 12:52:26 PM UTC+2 listmei...@gmail.com 
> wrote:
>
>> On Aug 05, 2021, at 05:15, Rainer Krug  wrote:
>>
>>
>> I have the following AppleScript to execute het selected text in R and 
>> return the focus to BBEdit:
>>
>> ...
>>
>> Now I would like to set the cursor in BBEDit to the next line after the 
>> selected text ore line it is in.
>>
>> --
>>
>> Hey Rainer,
>>
>> You can do something like this.
>>
>> --
>> Best Regards,
>> Chris
>>
>> --
>>
>> *tell* *application* "BBEdit"
>>
>> 
>> *set* startLineNum *to* startLine *of* selection
>> *set* selectedText *to* selection's contents
>>
>> 
>> *if* selectedText *is* "" *then*
>> *try*
>> *set* selectedText *to* contents *of* *line* startLineNum 
>> *of* *front* *document*
>> *on* *error*
>> *display dialog* "The active window must be an editor 
>> window, with a file opened. You want to run something in R? Well, tell me 
>> what!" with icon *note* buttons {"Got it!"} default button 1
>> *error* number -128
>> *end* *try*
>> *end* *if*
>>
>> 
>> *end* *tell*
>>
>> tell application "R"
>> cmd the_selection
>> end tell
>>
>> *tell* *application* "BBEdit"
>> *activate*
>> *tell* *front* *document*
>> *try*
>> *select* *insertion point* *before* *line* (startLineNum + 1)
>> *on* *error*
>> *select* *insertion point* *after* *line* startLineNum
>> *end* *try*
>> *end* *tell*
>> *end* *tell*
>>
>> --
>>
>>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/dd01b82c-b825-43eb-a2f6-b347dd110476n%40googlegroups.com.


Re: Set selection point to next line in AppleScript

2021-08-05 Thread Rainer Krug
Perfect. Thanks.


On Thursday, August 5, 2021 at 12:52:26 PM UTC+2 listmei...@gmail.com wrote:

> On Aug 05, 2021, at 05:15, Rainer Krug  wrote:
>
>
> I have the following AppleScript to execute het selected text in R and 
> return the focus to BBEdit:
>
> ...
>
> Now I would like to set the cursor in BBEDit to the next line after the 
> selected text ore line it is in.
>
> --
>
> Hey Rainer,
>
> You can do something like this.
>
> --
> Best Regards,
> Chris
>
> --
>
> *tell* *application* "BBEdit"
>
> 
> *set* startLineNum *to* startLine *of* selection
> *set* selectedText *to* selection's contents
>
> 
> *if* selectedText *is* "" *then*
> *try*
> *set* selectedText *to* contents *of* *line* startLineNum *of* 
> *front* *document*
> *on* *error*
> *display dialog* "The active window must be an editor window, 
> with a file opened. You want to run something in R? Well, tell me what!" with 
> icon *note* buttons {"Got it!"} default button 1
> *error* number -128
> *end* *try*
> *end* *if*
>
> 
> *end* *tell*
>
> tell application "R"
> cmd the_selection
> end tell
>
> *tell* *application* "BBEdit"
> *activate*
> *tell* *front* *document*
> *try*
> *select* *insertion point* *before* *line* (startLineNum + 1)
> *on* *error*
> *select* *insertion point* *after* *line* startLineNum
> *end* *try*
> *end* *tell*
> *end* *tell*
>
> --
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/f2d14080-418f-4bce-a0eb-c22f4c09fc3en%40googlegroups.com.


Re: Set selection point to next line in AppleScript

2021-08-05 Thread Christopher Stone
> On Aug 05, 2021, at 05:15, Rainer Krug  wrote:
> 
> I have the following AppleScript to execute het selected text in R and return 
> the focus to BBEdit:
> ...
> Now I would like to set the cursor in BBEDit to the next line after the 
> selected text ore line it is in.

Hey Rainer,

You can do something like this.

--
Best Regards,
Chris


tell application "BBEdit"

set startLineNum to startLine of selection
set selectedText to selection's contents

if selectedText is "" then
try
set selectedText to contents of line startLineNum of front document
on error
display dialog "The active window must be an editor window, with a 
file opened. You want to run something in R? Well, tell me what!" with icon 
note buttons {"Got it!"} default button 1
error number -128
end try
end if

end tell

tell application "R"
cmd the_selection
end tell

tell application "BBEdit"
activate
tell front document
try
select insertion point before line (startLineNum + 1)
on error
select insertion point after line startLineNum
end try
end tell
end tell


-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/2396E259-9608-4CEA-B626-EC8E0FAB4E88%40gmail.com.


Set selection point to next line in AppleScript

2021-08-05 Thread Rainer Krug
I have the following AppleScript to execute het selected text in R and 
return the focus to BBEdit:

*tell* *application* "BBEdit"

*set* the_selection *to* (selection *of* *front* *window* *as* *string*)

*if* (the_selection) *is* "" *then*

*try*

*set* the_selection *to* *line* (*get* startLine *of* selection) *of* 
*front* *window* *as* *string*

*on* *error*

*display dialog* "The active window must be an editor window, with a file 
opened. You want to run something in R? Well, tell me what!" with icon 
*note* buttons {"Got it!"} default button 1

*error* number -128

*end* *try*

*end* *if*

*end* *tell*


*tell* *application* "R"

*cmd* the_selection

*end* *tell*


*tell* *application* "System Events"

*tell* *process* "BBEdit"

*set* frontmost *to* *true*

*end* *tell*

*end* *tell*
Now I would like to set the cursor in BBEDit to the next line after the 
selected text ore line it is in.

an I do this?

Thanks,

Rainer

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/655cb19e-898a-4498-9cff-5bfcf4d1b210n%40googlegroups.com.