AppleScript Editor: collegamento alla linea di commento?

9

C'è una scorciatoia da tastiera per commentare le righe in AppleScript Editor?

Il comune Cmd + spostamento + / non funziona qui.

    
posta Matthieu Riegler 24.11.2013 - 21:34
fonte

1 risposta

1

Ho usato FastScripts per assegnare un collegamento a questo script:

set text item delimiters to linefeed
tell application "AppleScript Editor" to tell document 1
    set input to its text
    set {c1, c2} to character range of selection
    if c1 is 0 then
        set {p1, p2} to {1, 1}
    else
        set p1 to count paragraphs of text 1 thru c1 of input
        set p2 to count paragraphs of text 1 thru c2 of input
        if p1 is not p2 and {return, linefeed} contains item c2 of input then set p2 to p2 - 1
    end if
    set selection to paragraphs p1 thru p2
    do shell script "input=" & quoted form of (paragraphs p1 thru p2 of input as text) & "
if [[ -z $(sed -E '/^[[:space:]]*($|#|--)/d' <<< \"$input\") ]]; then
  sed -E 's/^([[:space:]]*)(#|--)[[:space:]]*/\1/g' <<< \"$input\"
else
  sed -E 's/^([[:space:]]*)/\1--/g' <<< \"$input\"
fi" without altering line endings
    set contents of selection to result
end tell
    
risposta data 25.11.2013 - 13:21
fonte

Leggi altre domande sui tag