加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wlgame-plugin.py 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
import sublime
import sublime_plugin
import os, sys
def plugin_loaded():
print("plugin_loaded")
settings = sublime.load_settings("wlgame-plugin.sublime-settings")
root = os.path.join(sublime.packages_path(), settings.get("project_name"))
sys.path.append(root)
def plugin_unloaded():
print("plugin_unloaded")
class wlgame_plugin(sublime_plugin.EventListener):
def on_window_command (self, window, command_name, args):
print(command_name)
def on_post_text_command(self, view, command_name, args):
if command_name != "insert":
return
isLuaFile = view.file_name().endswith(".lua")
if not isLuaFile:
return
selRegion = view.sel()[0]
pos = view.rowcol(selRegion.begin())
point = view.text_point(pos[0] - 1, pos[1])
selRegion = view.line(point)
line = view.line(selRegion)
content = view.substr(line).replace(" ", "").replace("\t", "")
print(content)
if content.replace(" ", "").startswith("---"):
print(pos[0])
if pos[0]-1 == 0:
view.run_command("wlgame_insert_lua_header")
else:
view.run_command("wlgame_insert_lua_func_comment")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化