本文整理匯總了Python中sublime_plugin.TextCommand方法的典型用法代碼示例。如果您正苦於以下問題:Python sublime_plugin.TextCommand方法的具體用法?Python sublime_plugin.TextCommand怎麽用?Python sublime_plugin.TextCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sublime_plugin
的用法示例。
在下文中一共展示了sublime_plugin.TextCommand方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import sublime_plugin [as 別名]
# 或者: from sublime_plugin import TextCommand [as 別名]
def __init__(self, *args, **kwargs):
self.settings = sublime.load_settings('Glue.sublime-settings')
self.stdout = ""
self.stderr = ""
self.exitcode = 1
self.userpath = self.settings.get('glue_userpath')
self.shellpath = self.settings.get('glue_shellpath')
self.original_env_path = os.environ['PATH']
self.ps1 = self.settings.get('glue_ps1')
self.start_dirpath = ""
self.current_dirpath = self.settings.get('glue_working_directory')
self.current_filepath = ""
self.attr_lock = threading.Lock() # thread lock for attribute reads/writes
sublime_plugin.TextCommand.__init__(self, *args, **kwargs)
#------------------------------------------------------------------------------
# [ run method ] - plugin start method
#------------------------------------------------------------------------------
示例2: run
# 需要導入模塊: import sublime_plugin [as 別名]
# 或者: from sublime_plugin import TextCommand [as 別名]
def run(self, edit):
"""Sublime Text executes this when you trigger the TextCommand."""
with Yapf(self.view) as yapf:
# no selection?
no_selection = all(s.empty() for s in self.view.sel())
if no_selection:
if not yapf.get_setting("use_entire_file_if_no_selection"):
sublime.error_message('A selection is required')
return
# format entire document
with PreserveSelectionAndView(self.view):
yapf.format(edit)
return
# otherwise format all (non-empty) ones
with PreserveSelectionAndView(self.view) as pv:
pv.sel = []
for s in self.view.sel():
if not s.empty():
new_s = yapf.format(edit, s)
pv.sel.append(new_s if new_s else s)
示例3: __init__
# 需要導入模塊: import sublime_plugin [as 別名]
# 或者: from sublime_plugin import TextCommand [as 別名]
def __init__(self, param):
# no super() call! this would get the references confused
if isinstance(param, sublime.Window):
self.window = param
self._window_command = True # probably called from build system
self.typ = WindowCommand
elif isinstance(param, sublime.View):
self.view = param
self._window_command = False
self.typ = TextCommand
else:
raise TypeError("Something really bad happened and you are responsible")
self._update_members()
示例4: __init__
# 需要導入模塊: import sublime_plugin [as 別名]
# 或者: from sublime_plugin import TextCommand [as 別名]
def __init__(self, view):
sublime_plugin.TextCommand.__init__(self, view)
self.settings = load_settings()