本文整理汇总了Python中sublime.View.window方法的典型用法代码示例。如果您正苦于以下问题:Python View.window方法的具体用法?Python View.window怎么用?Python View.window使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sublime.View
的用法示例。
在下文中一共展示了View.window方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_window_client_config
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def get_window_client_config(view: sublime.View) -> 'Optional[ClientConfig]':
window = view.window()
if window:
configs_for_window = window_client_configs.get(window.id(), [])
return get_scope_client_config(view, configs_for_window)
else:
return None
示例2: show_enable_config
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def show_enable_config(view: sublime.View, config: ClientConfig):
syntax = str(view.settings().get("syntax", ""))
message = "SublimeCodeIntel has found a language server for {}. Run \"Setup Language Server\" to start using it".format(
extract_syntax_name(syntax)
)
window = view.window()
if window:
window.status_message(message)
示例3: notify_did_save
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def notify_did_save(view: sublime.View):
file_name = view.file_name()
window = view.window()
if window and file_name:
if has_document_state(window, file_name):
client = client_for_view(view)
if client:
params = {"textDocument": {"uri": filename_to_uri(file_name)}}
client.send_notification(Notification.didSave(params))
else:
debug('document not tracked', file_name)
示例4: config_for_scope
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def config_for_scope(view: sublime.View) -> 'Optional[ClientConfig]':
# check window_client_config first
window = view.window()
if window:
configs_for_window = window_client_configs.get(window.id(), [])
window_client_config, window_score = _get_scope_client_config(view, configs_for_window)
else:
window_client_config, window_score = None, 0
global_client_config, global_score = _get_scope_client_config(view, client_configs.all)
if not window_client_config or global_score > window_score:
if global_client_config:
if window:
window_client_config = apply_window_settings(global_client_config, view)
add_window_client_config(window, window_client_config)
return window_client_config
else:
# always return a client config even if the view has no window anymore
return global_client_config
return window_client_config
示例5: initialize_on_open
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def initialize_on_open(view: sublime.View):
window = view.window()
if not window:
return
debug("initialize on open", window.id(), view.file_name())
if window_configs(window):
unload_old_clients(window)
window_id = window.id()
global didopen_after_initialize
config = config_for_scope(view)
if config:
if config.enabled:
if not is_ready_window_config(window, config.name):
open_after_initialize_by_window.setdefault(window_id, []).append(view)
start_window_client(view, window, config)
else:
debug(config.name, 'is not enabled')
示例6: update_diagnostics_in_status_bar
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def update_diagnostics_in_status_bar(view: sublime.View):
errors = 0
warnings = 0
window = view.window()
if window:
diagnostics_by_file = get_window_diagnostics(window)
if diagnostics_by_file:
for file_path, source_diagnostics in diagnostics_by_file.items():
if source_diagnostics:
for origin, diagnostics in source_diagnostics.items():
for diagnostic in diagnostics:
if diagnostic.severity == DiagnosticSeverity.Error:
errors += 1
if diagnostic.severity == DiagnosticSeverity.Warning:
warnings += 1
count = 'E: {} W: {}'.format(errors, warnings)
view.set_status('code_intel_errors_warning_count', count)
示例7: notify_did_open
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def notify_did_open(view: sublime.View):
config = config_for_scope(view)
client = client_for_view(view)
if client and config:
view.settings().set("show_definitions", False)
window = view.window()
view_file = view.file_name()
if window and view_file:
if not has_document_state(window, view_file):
ds = get_document_state(window, view_file)
ds.languageId = config.get_language_id(view)
if settings.show_view_status:
view.set_status("code_intel_clients", config.name)
params = {
"textDocument": {
"uri": filename_to_uri(view_file),
"languageId": ds.languageId,
"text": view.substr(sublime.Region(0, view.size())),
"version": ds.version
}
}
client.send_notification(Notification.didOpen(params))
示例8: notify_did_change
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def notify_did_change(view: sublime.View):
file_name = view.file_name()
window = view.window()
if window and file_name:
if view.buffer_id() in pending_buffer_changes:
del pending_buffer_changes[view.buffer_id()]
config = config_for_scope(view)
client = client_for_view(view)
if client and config:
uri = filename_to_uri(file_name)
languageId = config.get_language_id(view)
ds = get_document_state(window, file_name)
if ds.languageId == languageId:
params = {
"textDocument": {
"uri": uri,
"version": ds.inc_version(),
},
"contentChanges": [{
"text": view.substr(sublime.Region(0, view.size()))
}]
}
client.send_notification(Notification.didChange(params))
else:
# The languageId has changed, reopen file
ds.languageId = languageId
params = {"textDocument": {"uri": uri}}
client.send_notification(Notification.didClose(params))
params = {
"textDocument": {
"uri": uri,
"languageId": ds.languageId,
"text": view.substr(sublime.Region(0, view.size())),
"version": ds.inc_version(),
}
}
client.send_notification(Notification.didOpen(params))
示例9: session_for_view
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def session_for_view(view: sublime.View) -> 'Optional[Session]':
return _session_for_view_and_window(view, view.window())
示例10: client_for_view
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import window [as 别名]
def client_for_view(view: sublime.View) -> 'Optional[Client]':
return _client_for_view_and_window(view, view.window())