比起我搞不定的VScode的Lua调试插件,ZeroBraneStudio的调试功能完善且容易上手。然鹅这款IDE的默认配色实在很丑(在配色方案偏好设置的最后一行告诉了怎么玩预设的几款配色,DIY一下还是看得过去的)。
如何让ZBStudio开发体验像VScode一样Smooth呢?官方指南
本文介绍了几个Customization Tricks:
Ctrl+Shift+O: 打开/关闭console
官方指南 bind-new-keyboard-shortcuts-docs
To support more actions: keyboard-commands-list
举个栗子, 以下修改的文件其实是/opt/zbstudio/src/editor/keymap.lua
如果你不想改动源码文件的话,同样的修改对于/opt/zbstudio/cfg/user.lua一样生效。
增加操作
ide.config.editor.keymap = {
--...
--删除当前行
["Shift-Delete"] = {("DEL"):byte(), wxstc.wxSTC_SCMOD_SHIFT, wxstc.wxSTC_CMD_DELLINERIGHT, "Unix"},
--...
}
对已有的操作重定义快捷键
ide.config.keymap = {
--...
--修改前是空值,这个操作是选中所有instance重命名,默认是由Ctrl-DblClick触发,修改后还可以由Alt+A触发。
[ID.RENAMEALLINSTANCES] = "Alt-A",
--修改前是空值,这个操作是将选中的变量快速添加到watch项,修改后可以用F1触发。
[ID.QUICKADDWATCH] = "F1",
}
在zerobrane studio中,我们想要调试一个脚本如下:
local foo = 0
for i = 1, foo+5 do
foo = i
print("Loop")
end
我们在第3行打上断点,但是我们只想调试当i=3的时候,这样写,
local dbg=require("mobdebug")
dbg.start()
dbg.off()
local foo = 0
for i = 1, foo+5 do
--进入调试状态
if(i==3)then
dbg.on()
end
foo = i
print("Loop")
--退出调试状态
if(i==3)then
dbg.off()
end
end
执行(F6)脚本即可,我们设置的断点就是一个条件断点了。
The debugging of coroutines is disabled by default. To enable debugging in coroutines, including stepping into resume/yield calls and triggering of breakpoints, you may do one of the following:
require('mobdebug').coro()
call to your scriptrequire('mobdebug').on()
call to that coroutine fragmentYou can drill down to get values of individual elements in tables in these windows.
View | Watch Window
View | Stack Window
快捷键 | 功能 |
---|---|
Insert | Add watch |
Delete | Delete Watch |
F1 | Quick Add Watch |
The Static analyzer allows to detect typos, non-localized variables, and unused parameters. Before running your code:
Project | Analyze