diff options
| author | Ralf Luther <luther.ralf@gmail.com> | 2019-03-27 20:23:17 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@aicp-server-3> | 2019-03-27 20:23:17 +0000 |
| commit | 1ce3a9d272e564b22a1333a1e36a3d3ab7cfab01 (patch) | |
| tree | 391382eadd4fec5bb480f2e8934fa352770221d1 /clang-r353983/share/clang/clang-format-bbedit.applescript | |
| parent | d1d48b140bafaa8a50107292f5fce95562575765 (diff) | |
| parent | 4f56932d3416ac03f646bc1a611b3135fec2fe08 (diff) | |
Merge "Update prebuilt Clang to r353983." into p9.0HEADp9.0-backupp9.0
Diffstat (limited to 'clang-r353983/share/clang/clang-format-bbedit.applescript')
| -rwxr-xr-x | clang-r353983/share/clang/clang-format-bbedit.applescript | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang-r353983/share/clang/clang-format-bbedit.applescript b/clang-r353983/share/clang/clang-format-bbedit.applescript new file mode 100755 index 00000000..fa88fe90 --- /dev/null +++ b/clang-r353983/share/clang/clang-format-bbedit.applescript @@ -0,0 +1,27 @@ +-- In this file, change "/path/to/" to the path where you installed clang-format +-- and save it to ~/Library/Application Support/BBEdit/Scripts. You can then +-- select the script from the Script menu and clang-format will format the +-- selection. Note that you can rename the menu item by renaming the script, and +-- can assign the menu item a keyboard shortcut in the BBEdit preferences, under +-- Menus & Shortcuts. +on urlToPOSIXPath(theURL) + return do shell script "python -c \"import urllib, urlparse, sys; print urllib.unquote(urlparse.urlparse(sys.argv[1])[2])\" " & quoted form of theURL +end urlToPOSIXPath + +tell application "BBEdit" + set selectionOffset to characterOffset of selection + set selectionLength to length of selection + set fileURL to URL of text document 1 +end tell + +set filePath to urlToPOSIXPath(fileURL) +set newContents to do shell script "/path/to/clang-format -offset=" & selectionOffset & " -length=" & selectionLength & " " & quoted form of filePath + +tell application "BBEdit" + -- "set contents of text document 1 to newContents" scrolls to the bottom while + -- replacing a selection flashes a bit but doesn't affect the scroll position. + set currentLength to length of contents of text document 1 + select characters 1 thru currentLength of text document 1 + set text of selection to newContents + select characters selectionOffset thru (selectionOffset + selectionLength - 1) of text document 1 +end tell |
