On 06/09/2018, at 22:43, Jean-Christophe Helary <[email protected] 
<mailto:[email protected]>> wrote:
> What's the easy way to select a block of lines specified by line numbers?


Hey Jean-Christophe,

As far as I know there isn't one.

BBEdit does have a jump-to-line function (Cmd-J), but it doesn't allow for a 
selection

You can roll-your-own and get as sophisticated as you want.

The appended script will pop-up a dialog and will accept the following input:

<start-line-num><space><end-line-num>  ==  A selection range from start-line to 
end-line.

<num>  == Select current line + num

-<num> == Select current line - num

.<space><end-line-num>  ==  Select current line to absolute end-line-num.

That's as fancy as I'm willing to make it at this time, but with all the tools 
available you can get substantially more sophisticated.

--
Take Care,
Chris

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/06/10 00:08
# dMod: 2018/06/10 00:56
# Appl: BBEdit
# Task: Select Lines with User Input from Dialog
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Select, @Lines, @User, @Input, @Dialog
----------------------------------------------------------------

property defaultDialogText : ""

set AppleScript's text item delimiters to {" "}

set defaultDialogText to text returned of ¬
    (display dialog "Current Line +     ==        #" & linefeed & ¬
        "Current Line - ==      -#" & linefeed & ¬
        "Line Range             ==      # #" with title "Enter Line Range for 
Selection" default answer defaultDialogText)

copy defaultDialogText to lineRange

set dialogTextItems to text items of lineRange

tell application "BBEdit"
    tell front text window
        set currentLine to startLine of selection
        
        if length of dialogTextItems = 1 then
            set dialogText to item 1 of dialogTextItems
            
            if dialogText starts with "-" then
                set firstLine to currentLine + dialogText
                set lastLine to currentLine
            else
                set firstLine to currentLine
                set lastLine to currentLine + dialogText
            end if
            
        else if length of dialogTextItems = 2 then
            set {firstLine, lastLine} to dialogTextItems
        end if
        
        if firstLine = "." then
            set firstLine to currentLine
        end if
        
        select (lines firstLine thru lastLine)
    end tell
end tell

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

-- 
This is the BBEdit Talk public discussion group. 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>
--- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to