本文整理汇总了Python中sublime.set_clipboard方法的典型用法代码示例。如果您正苦于以下问题:Python sublime.set_clipboard方法的具体用法?Python sublime.set_clipboard怎么用?Python sublime.set_clipboard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sublime
的用法示例。
在下文中一共展示了sublime.set_clipboard方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def run(self, *args, **kwargs):
view = sublime.active_window().active_view()
#settings = sublime.load_settings('KSP.sublime-settings')
#scheme_file = settings.get('color_scheme', 'Packages/SublimeKSP/KScript Light.tmTheme')
scheme_file = 'Packages/SublimeKSP/KScript Light.tmTheme'
plist = readPlistFromBytes(sublime.load_binary_resource(scheme_file))
result = ['[pre]']
start, end = view.sel()[0].a, view.sel()[0].b
if start == end:
start, end = 0, view.size()
for a, b, scopes in get_ranges(view.scope_name(i) for i in range(start, end)):
result.append(self.apply_style(scopes, plist, view.substr(sublime.Region(start+a, start+b))))
result.append('[/pre]')
sublime.set_clipboard(''.join(result))
示例2: action_result
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def action_result(action):
global result_js
global region_selected
view = sublime.active_window().active_view()
sel = region_selected
str_selected = view.substr(sel).strip()
if action == "copy_to_clipboard" :
sublime.set_clipboard(result_js)
elif action == "replace_text" :
view.run_command("replace_text")
elif action == "view_result_formatted":
view.run_command("view_result_formatted")
view.hide_popup()
result_js = ""
示例3: click
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def click(self, text: str):
values = [
ui.InputListItem(lambda: sublime.set_clipboard(text), "Copy"),
]
for match in url_matching_regex.findall(text):
values.insert(0, ui.InputListItem(lambda: webbrowser.open_new_tab(match[0]), "Open"))
if self.clicked_menu:
values[0].run()
self.clicked_menu.cancel()
return
values[0].text += "\t Click again to select"
self.clicked_menu = ui.InputList(values, text).run()
await self.clicked_menu
self.clicked_menu = None
示例4: _insert_snippet
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def _insert_snippet(window: sublime.Window, snippet: dict):
content = json.dumps(snippet, indent="\t")
content = content.replace('\\\\', '\\') # remove json encoded \ ...
project = window.project_file_name()
if project:
view = await core.sublime_open_file_async(window, project)
region = view.find('''"\s*debug.configurations\s*"\s*:\s*\[''', 0)
view.sel().clear()
view.sel().add(sublime.Region(region.b, region.b))
view.run_command('insert', {
'characters': '\n'
})
view.run_command('insert_snippet', {
'contents': content + ','
})
else:
sublime.set_clipboard(content)
core.display('Unable to insert configuration into sublime-project file: Copied to clipboard instead')
示例5: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def run(self, edit):
# Get selected region or use line that cursor is on if nothing is
# selected
selected_region = self.view.sel()[0]
if selected_region.empty():
selected_region = self.view.line(selected_region)
# Clean the selected text and move it into clipboard
selected_text = self.view.substr(selected_region)
selected_lines = selected_text.split("\n")
clean_contents_to_copy = ""
for line in selected_lines:
clean_contents_to_copy = clean_contents_to_copy + line.rstrip() + "\n"
sublime.set_clipboard(clean_contents_to_copy[:-1])
示例6: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def run(self, edit):
full_path = self.view.file_name()
if full_path != None:
str_list = full_path.split(baseutil.get_slash())
file_name = str(str_list[-1])
sublime.set_clipboard(file_name)
sublime.status_message("Copy File Name : %s " % file_name)
示例7: clear_clipboard
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def clear_clipboard(view, password):
if sublime.get_clipboard() == password:
sublime.set_clipboard('')
view.window().status_message('Network Tech: Password cleared from clipboard')
示例8: result_handler
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def result_handler(view, encoded_password, decoded_password, index):
if index is RESULTS.cancel:
return
elif index is RESULTS.display:
message = 'Encoded: {}\nDecoded: {}'.format(encoded_password, decoded_password)
sublime.message_dialog(message)
elif index is RESULTS.clipboard:
sublime.set_clipboard(decoded_password)
sublime.set_timeout_async(
functools.partial(clear_clipboard, view, decoded_password),
10000
)
示例9: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def run(self, edit):
suggested_setting = self._build_suggested_setting()
if not suggested_setting:
sublime.set_clipboard('Unable to create syntax setting')
else:
sublime.set_clipboard(suggested_setting)
示例10: create
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def create(data):
try:
g = gist.Gist(
token=settings.get('access_token'),
http_proxy=settings.get('http_proxy'),
https_proxy=settings.get('https_proxy')
).create(data)
msg = (
'Sync Settings:\n\n'
'Your gist `{}` was created successfully\n\n'
'Do you want to overwrite the current `gist_id` property with the created gist?'
)
answer = sublime.yes_no_cancel_dialog(msg.format(g['id']))
if answer == sublime.DIALOG_NO:
sublime.set_clipboard(g['id'])
sublime.status_message('Sync Settings: the created gist`s id, has been copied to clipboard')
if answer == sublime.DIALOG_YES:
commit = g['history'][0]
settings.update('gist_id', g['id'])
version.update_config_file({
'hash': commit['version'],
'created_at': commit['committed_at'],
})
sublime.status_message('Sync Settings: gist created')
except gist.NotFoundError as e:
msg = (
'Sync Settings:\n\n'
'Apparently the token was not created with gist scope enabled.\n\n'
'Please, check your token or create a new one.\n\n'
'more info: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/'
)
sublime.message_dialog(msg.format(str(e)))
except Exception as e:
logger.exception(e)
sublime.message_dialog('Sync Settings:\n\n{}'.format(str(e)))
示例11: copy
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def copy(el):
return sublime.set_clipboard(el)
示例12: on_phantom_close
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def on_phantom_close(self, href):
href_parts = href.split("-")
if len(href_parts) > 1:
intent = href_parts[0]
sha = href_parts[1]
# The SHA output by git-blame may have a leading caret to indicate
# that it is a "boundary commit". That useful information has
# already been shown in the phantom, so strip it before going on to
# use the SHA programmatically.
sha = sha.strip("^")
if intent == "copy":
sublime.set_clipboard(sha)
sublime.status_message("Git SHA copied to clipboard")
elif intent == "show":
try:
desc = self.get_commit(sha, self.view.file_name())
except Exception as e:
communicate_error(e)
return
buf = self.view.window().new_file()
buf.run_command(
"blame_insert_commit_description",
{"desc": desc, "scratch_view_name": "commit " + sha},
)
else:
self.view.erase_phantoms("git-blame")
else:
self.view.erase_phantoms("git-blame")
# ------------------------------------------------------------
示例13: copy_sha
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def copy_sha(self):
sublime.set_clipboard(self.git("rev-parse", self._commit_hash).strip())
示例14: copy_sha
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def copy_sha(self, commit_hash):
sublime.set_clipboard(self.git("rev-parse", commit_hash).strip())
示例15: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import set_clipboard [as 别名]
def run(self):
sublime.active_window ().run_command ("copy")
sublime.set_clipboard (re.sub (r"^\s*[0-9]+.", "",
sublime.get_clipboard (), flags=re.MULTILINE))