10 Star 0 Fork 6

OpenHarmony-TPC/chromium_buildtools_script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
clang-format-bbedit.applescript 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
李想 提交于 2023-08-12 11:00 . chromium 99.0.4844.88 origin init
-- 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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony-tpc/chromium_buildtools_script.git
git@gitee.com:openharmony-tpc/chromium_buildtools_script.git
openharmony-tpc
chromium_buildtools_script
chromium_buildtools_script
master

搜索帮助