代码拉取完成,页面将自动刷新
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")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。