gpt4 book ai didi

build-automation - 如何制作 Sublime Text 2 快捷方式来在 Mac 上运行处理草图?

转载 作者:行者123 更新时间:2023-12-03 23:49:37 24 4
gpt4 key购买 nike

我正在使用 SublimeText 2 来编写我的处理草图,但是每次我需要运行程序时,我都必须切换到处理并单击运行按钮,Textmate 有一个包可以自动执行此过程,我想用SublimeText 但我不知道如何

顺便说一下,我正在使用 Mac OSX Lion

最佳答案

感谢早午餐 Storm 的建议!我修改了你的方法,以便在 Sublime 中打开的处理文件可以直接发送到处理应用程序。首先,我下载并安装了 TextMate 处理包,以便 .pde 文件在 Sublime ( http://www.onebitwonder.com/projects/processing ) 中被正确识别为处理文档(并突出显示语法)。如果您浏览该 tmbundle,则必须修改一个 TextMate 语言定义文件 (Processing.tmbundle/Syntaxes/Processing.tmLanguage)。在该文件的底部附近有一行:
<string>source.java-processing</string>
此行必须更改为:
<string>source.pde</string>
保存 Processing.tmLanguage 后,您可以将整个 Processing.tmbundle 包放到 Sublime 包目录中。现在在 Sublime 中打开一个 .pde 文档。在 Sublime 窗口的右下角是一个文档类型标识符,可能会说“纯文本”。单击该标识符并选择“以当前扩展名打开所有内容...”并选择“正在处理”,它现在应该在列表中。我写了两个 AppleScripts 来启动和运行 Processing 和一个 shell 脚本来驱动它们(这是我让 AppleScripts 按顺序从 Sublime 正确启动的唯一方法)。

如果第一个脚本尚未运行,则它会启动 Processing。此步骤是必要的,因为如果 Processing 未运行,则必须在 Processing 注册击键之前插入延迟(启动期间会出现几秒钟的闪屏)。 3 秒的延迟适用于我的系统,但您可能需要根据您的硬件延长延迟。也许其他人可以想出一种更优雅的方式让 AppleScript 等待处理通过启动画面。

第一个 AppleScript(我命名为“first_processing.scpt”):

--check to see if Processing is running
tell application "System Events"
set x to (count (every process whose creator type is "Pde1"))
end tell

--if Processing is not running, open Processing and delay
--for three seconds to allow time for splash screen
--to disappear and to allow keystrokes to be
--registered
if x is 0 then
activate application "Processing"
delay 3
end if

第二个applescript发送一个按键来运行你的处理程序(名为“second_processing.scpt”):
tell application "Processing"
activate
end tell

tell application "System Events"
--deliver the "run" command
delay 0.1
keystroke "r" using command down
--hide Processing; delay is necessary for reliable hiding
--you may want to turn off hiding to see error messages
delay 0.2
keystroke "h" using command down
end tell

驱动程序 shell 脚本(名为“launch_processing_file.sh”):
osascript ~/Documents/AppleScript_Library/processing/first_processing.scpt
open -a Processing $1
osascript ~/Documents/AppleScript_Library/processing/second_processing.scpt

最后,用于处理的 Sublime 构建系统(以“.sublime-build”扩展名存储在您的用户目录中):
{
"cmd": ["sh", "full_path_to_shell_script/launch_processing_file.sh", "$file"],
"selector": "source.pde"
}

请注意,您必须在处理首选项中选择“使用外部编辑器”,此方法才能正常工作。另请注意,您的处理文件必须包含在具有相同名称的文件夹中。我可能会编写一个脚本来为裸处理文件创建正确的封闭文件夹,但目前该方面并未自动处理。享受!

附言

这是我在这里的第一篇文章。多么棒的网站啊!

关于build-automation - 如何制作 Sublime Text 2 快捷方式来在 Mac 上运行处理草图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9364483/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com