本文整理汇总了Python中sublime.active_window函数的典型用法代码示例。如果您正苦于以下问题:Python active_window函数的具体用法?Python active_window怎么用?Python active_window使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了active_window函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_declaration
def find_declaration(data):
data = data['Data']
fname = data['File']
row = data['Line'] + 1
col = data['Column'] + 1
encoded = "{0}:{1}:{2}".format(fname, row, col)
sublime.active_window().open_file(encoded, sublime.ENCODED_POSITION)
示例2: run
def run(self):
sublime.active_window().run_command(
'open_dir',
{
'dir': self.templates_path_string()
}
)
示例3: handler
def handler(self, name, data):
if name == 'create_user':
del data['name']
try:
floorc = BASE_FLOORC + '\n'.join(['%s %s' % (k, v) for k, v in data.items()]) + '\n'
with open(G.FLOORC_PATH, 'wb') as floorc_fd:
floorc_fd.write(floorc.encode('utf-8'))
utils.reload_settings()
if False in [bool(x) for x in (G.USERNAME, G.API_KEY, G.SECRET)]:
sublime.message_dialog('Something went wrong. You will need to sign up for an account to use Floobits.')
api.send_error({'message': 'No username or secret'})
else:
p = os.path.join(G.BASE_DIR, 'welcome.md')
with open(p, 'wb') as fd:
text = welcome_text % (G.USERNAME, self.host)
fd.write(text.encode('utf-8'))
d = utils.get_persistent_data()
d['auto_generated_account'] = True
utils.update_persistent_data(d)
G.AUTO_GENERATED_ACCOUNT = True
sublime.active_window().open_file(p)
except Exception as e:
msg.error(e)
try:
d = utils.get_persistent_data()
d['disable_account_creation'] = True
utils.update_persistent_data(d)
finally:
self.stop()
示例4: run
def run(self):
user_settings = os.path.join(
sublime.packages_path(),
"User",
"LaTeXTools.sublime-settings"
)
load_default = False
if not os.path.exists(user_settings):
migrate = sublime.ok_cancel_dialog(
'You do not currently have a personalized '
'LaTeXTools.sublime-settings file.\n\n'
'Create a copy of the default settings file in '
'your User directory?'
)
if migrate:
sublime.active_window().run_command('latextools_migrate')
else:
load_default = True
self.view = sublime.active_window().open_file(user_settings)
if load_default:
sublime.set_timeout(self.set_content, 1)
示例5: run
def run(self, edit, event):
if self.symbol_details:
view_path = self.symbol_details[0]
focus_region = self.symbol_details[1]
# collapse the region to a single point, the region start
focus_region = sublime.Region(focus_region.begin(), focus_region.begin())
# get the view with this path
view = sublime.active_window().find_open_file(view_path)
if view:
self.showSymbol(view, focus_region)
else:
# weird issue, but unless we open the file with 'ENCODED_POSITION' it won't scroll afterwards
# https://github.com/SublimeTextIssues/Core/issues/538
view = sublime.active_window().open_file("%s:%d:%d" % (view_path, 1, 0), sublime.ENCODED_POSITION)
def viewLoadedTimeout():
# we can run methods only on loaded views
if not view.is_loading():
self.showSymbol(view, focus_region)
else:
sublime.set_timeout(viewLoadedTimeout, 100)
# open is asynchronous, wait for a bit and then try to focus
sublime.set_timeout(viewLoadedTimeout, 100)
示例6: createWindowWithText
def createWindowWithText(self, textToDisplay, fileType, showResultInSameFile):
if not(showResultInSameFile):
view = sublime.active_window().new_file()
openedNewView = True
else:
view = self.findHttpResponseView()
openedNewView = False
if view is None:
view = sublime.active_window().new_file()
openedNewView = True
edit = view.begin_edit()
if not(openedNewView):
view.insert(edit, 0, "\n\n\n")
view.insert(edit, 0, textToDisplay)
view.end_edit(edit)
view.set_scratch(True)
view.set_read_only(False)
view.set_name("http response")
if fileType == HttpRequester.FILE_TYPE_HTML:
view.set_syntax_file("Packages/HTML/HTML.tmLanguage")
if fileType == HttpRequester.FILE_TYPE_JSON:
view.set_syntax_file("Packages/JavaScript/JSON.tmLanguage")
if fileType == HttpRequester.FILE_TYPE_XML:
view.set_syntax_file("Packages/XML/XML.tmLanguage")
return view.id()
示例7: on_list_selected_done
def on_list_selected_done(self, picked):
if picked == -1:
self.view.sel().clear()
for each in self.return_to:
self.view.sel().add(each)
self.view.show(self.view.sel())
else:
titles = self.get_comment_titles()
title = titles[picked]
row = title['line']
point = self.view.text_point(row, 0)
line_region = self.view.line(point)
# Reference the 'text' within the line only
text = title['text']
text = re.escape(text)
text = text.replace('\>', '>') # ">" does not work when escaped
text_region = self.view.find(text, line_region.a)
# view.rowcol() returns a zero based line number
line = int(title['line'])+1
# Use goto_line to move the document then highlight
if sublime.active_window().active_view():
sublime.active_window().active_view().run_command(
"goto_line", {"line": line}
)
self.view.sel().clear()
self.view.sel().add(text_region)
示例8: handle_result
def handle_result(self, cmd, outfile, retCode, output):
if retCode:
if output:
sublime.error_message(' '.join(cmd) + '\r\n\r\n' + output.decode('utf-8'))
else:
if self.get_setting('open_file'):
sublime.active_window().open_file(outfile)
示例9: run
def run(self, edit):
# print("test = " + str(Settings.get("test", "default")))
# print("Active window - " + sublime.active_window().project_file_name())
# deleteAllServers()
# loc = "http://localhost:62562/ready"
# print("Connecting to: " + loc)
# proxies={'http':None}
# # print(urllib.request.FancyURLopener({}).open(loc).read())
# # print(urllib.request.urlopen(loc, proxies={}).read())
# proxy_handler = urllib.request.ProxyHandler({})
# opener = urllib.request.build_opener(proxy_handler)
# opener.open('http://localhost:62562/ready')
# print(str(opener.open(loc)))
# print(str(opener.open(loc).read()))
# print(urllib.request.urlopen(loc, proxies={}).read())
window = sublime.active_window()
pt = window.create_output_panel("paneltest")
pt.set_read_only(False)
# edit = pt.begin_edit()
pt.insert(edit, pt.size(), "Writing...2")
pt.set_read_only(True)
# pt.end_edit(edit)
window.run_command("show_panel", {"panel": "output.paneltest"})
window = sublime.active_window()
示例10: connection_error
def connection_error(message):
"""
Template for showing error message on connection error/loss.
Keyword arguments:
message -- Exception/reason of connection error/loss.
"""
sublime.error_message("Please restart Xdebug debugging session.\nDisconnected from Xdebug debugger engine.\n" + message)
info("Connection lost with debugger engine.")
debug(message)
# Reset connection
try:
S.SESSION.clear()
except:
pass
finally:
S.SESSION = None
S.SESSION_BUSY = False
S.BREAKPOINT_EXCEPTION = None
S.BREAKPOINT_ROW = None
S.BREAKPOINT_RUN = None
S.CONTEXT_DATA.clear()
async_session = SocketHandler(ACTION_WATCH)
async_session.start()
# Reset layout
sublime.active_window().run_command('xdebug_layout')
# Render breakpoint markers
render_regions()
示例11: packagesComplete
def packagesComplete(data):
global INSTALLED_PACKAGES, DEFAULT_PACKAGES
INSTALLED_PACKAGES = data["installed_packages"]
DEFAULT_PACKAGES = data["default_packages"]
installed_menu = {
"selected_index": 1,
"items": [["Back", "Back to previous menu"]],
"actions": [
{
"name": "package_manager"
}
]
}
# Installed packages
install_update = False
for package in getInstalledPackages():
install_update = True
installed_menu["actions"].append({"command": "javatar_install", "args": {"installtype": "uninstall_package", "name": package["name"], "filename": package["path"]}})
installed_menu["items"].append([package["name"], "Installed (" + toReadableSize(package["path"]) + ")."])
if install_update:
installed_menu["selected_index"] = 2
sublime.active_window().run_command("javatar", {"replaceMenu": {
"name": "uninstall_packages",
"menu": installed_menu
}})
from .javatar_updater import updatePackages
updatePackages()
示例12: get_target_ros_path
def get_target_ros_path(user_query=True):
ros_path_settings = sublime.load_settings(ROS_PATH_KEY)
path = ros_path_settings.get("path", "")
if path == "" and user_query:
sublime.message_dialog(MESSAGE_NO_KEY)
sublime.active_window().show_input_panel("Target ROS path:", "", save_ros_target_path, None, None)
return path
示例13: on_ch_settings_change
def on_ch_settings_change(self):
sets = sublime.load_settings(settings_file)
enabled = sets.get("enabled")
if enabled != self.settings["enabled"]:
self.settings["enabled"] = enabled
if not enabled:
self.do_disable()
else:
self.do_enable()
style = sets.get("style")
if style != self.settings["style"]:
self.settings["style"] = style
self.on_selection_modified(sublime.active_window().active_view())
ha_style = sets.get("ha_style")
if ha_style != self.settings["ha_style"]:
self.settings["ha_style"] = ha_style
self.on_activated(sublime.active_window().active_view())
icons_all = sets.get("icons_all")
if icons_all != self.settings["icons_all"]:
self.settings["icons_all"] = icons_all
self.on_activated(sublime.active_window().active_view())
icons = sets.get("icons")
if icons != self.settings["icons"]:
self.settings["icons"] = icons
self.on_selection_modified(sublime.active_window().active_view())
color_formats = sets.get("color_formats")
if color_formats != self.settings["color_formats"]:
self.settings["color_formats"] = color_formats
self.settings["color_fmts"] = list(map(get_format, color_formats))
示例14: run
def run(self, edit):
search_text = ''
s = OnlineSearcher()
for selection in self.view.sel():
search_text = self.view.substr(selection)
sublime.active_window().show_input_panel('Search online for', search_text,s.search, None, None)
示例15: on_open_declaration
def on_open_declaration(location):
"""Call this callback when link to type is clicked in info popup.
Opens location with type declaration
"""
sublime.active_window().open_file(location, sublime.ENCODED_POSITION)