本文整理汇总了Python中sublime.View类的典型用法代码示例。如果您正苦于以下问题:Python View类的具体用法?Python View怎么用?Python View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_data_tooltip
def prepare_data_tooltip(
self, view: sublime.View, data: Dict[str, Any]) -> Any:
"""Prepare the returned data for tooltips
"""
merge_doc = get_settings(view, 'merge_signatures_and_doc')
if (data['success'] and 'No docstring' not
in data['doc'] and data['doc'] != 'list\n'):
try:
i = data['doc'].split('<br>').index("")
except ValueError:
self.signature = data['doc']
self.doc = ''
if self._signature_excluded(self.signature):
return
return self._show_popup(view)
if merge_doc:
self.doc = '<br>'.join(data['doc'].split('<br>')[i:]).replace(
" ", " ")
self.signature = '<br> '.join(
data['doc'].split('<br>')[0:i])
if self.signature is not None and self.signature != "":
if not self._signature_excluded(self.signature):
return self._show_popup(view)
if view.is_popup_visible():
view.hide_popup()
view.erase_status('anaconda_doc')
示例2: on_modified
def on_modified(self, view: sublime.View) -> None:
"""Called after changes has been made to a view
"""
if view.command_history(0)[0] in ("expand_tabs", "unexpand_tabs"):
return
if not is_python(view) or not get_settings(view, 'display_signatures'):
return
try:
location = view.rowcol(view.sel()[0].begin())
if view.substr(view.sel()[0].begin()) in ['(', ')']:
location = (location[0], location[1] - 1)
data = prepare_send_data(location, 'doc', 'jedi')
use_tooltips = get_settings(
view, 'enable_signatures_tooltip', True
)
st_version = int(sublime.version())
if st_version >= 3070:
data['html'] = use_tooltips
currying = partial(self.prepare_data_status, view)
if use_tooltips and st_version >= 3070:
currying = partial(self.prepare_data_tooltip, view)
Worker().execute(currying, **data)
except Exception as error:
logging.error(error)
示例3: _show_status
def _show_status(self, view: sublime.View) -> None:
"""Show message in the view status bar
"""
view.set_status(
'anaconda_doc', 'Anaconda: {}'.format(self.signature)
)
示例4: is_scope
def is_scope(view: sublime.View, scope: str) -> bool:
sel = view.sel()
try:
return view.match_selector(sel[0].begin(), scope)
except IndexError:
# If in doubt, let's return `False`.
return False
示例5: last_block_in_region
def last_block_in_region(
view: sublime.View,
begin: int,
scope: str,
end: Optional[int] = None,
skip: int = SKIP_ANYTHING,
) -> Optional[Tuple[int, int]]:
skipper = SKIPPERS.get(skip, do_skip_anything)
stop = view.size() if end is None else end
empty = True
while (
stop > begin and
not view.match_selector(stop, scope) and
skipper(view, stop)
):
stop -= 1
start = stop
while start > begin and view.match_selector(start, scope):
start -= 1
empty = False
if empty:
return None
return start + 1, stop + 1
示例6: _session_for_view_and_window
def _session_for_view_and_window(view: sublime.View, window: 'Optional[sublime.Window]') -> 'Optional[Session]':
if not window:
debug("no window for view", view.file_name())
return None
if view.size() > 1000000:
printf("file is too big, ignoring!")
return False
config = config_for_scope(view)
if not config:
debug("config not available for view", view.file_name())
return None
window_config_states = window_configs(window)
if config.name not in window_config_states:
debug(config.name, "not available for view",
view.file_name(), "in window", window.id())
return None
else:
session = window_config_states[config.name]
if session.state == ClientStates.READY:
return session
else:
return None
示例7: show_enable_config
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)
示例8: modified_buffer
def modified_buffer(self, view: sublime.View) -> str:
"""Guru needs this to use unsaved buffers instead of files
"""
code = view.substr(sublime.Region(0, view.size()))
return '\n'.join([
view.file_name(), str(len(code.encode('utf8'))), code
])
示例9: get_document_position
def get_document_position(view: sublime.View, point) -> 'Optional[OrderedDict]':
file_name = view.file_name()
if file_name:
if not point:
point = view.sel()[0].begin()
d = OrderedDict() # type: OrderedDict[str, Any]
d['textDocument'] = {"uri": filename_to_uri(file_name)}
d['position'] = offset_to_point(view, point).to_lsp()
return d
else:
return None
示例10: notify_did_save
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)
示例11: try_jump_to_def_aux
def try_jump_to_def_aux(view: sublime.View, name: str) -> None:
start_time = time.time()
while view.is_loading():
time.sleep(0.01)
if time.time() - start_time > 1:
return
symbols = {strip_prefix(text): pos for (pos, text) in view.symbols()}
if name in symbols:
region = symbols[name]
view.run_command(
"simple_context_show_selection",
{"regions": [(region.a, region.b)]},
)
示例12: enclosing_block
def enclosing_block(
view: sublime.View, point: int, scope: str, end: Optional[int] = None,
) -> Optional[Tuple[int, int]]:
start = stop = point
while start > 0 and view.match_selector(start, scope):
start -= 1
end_ = view.size() if end is None else end
while stop < end_ and view.match_selector(stop, scope):
stop += 1
if start < stop:
return start + 1, stop
return None
示例13: update_diagnostics_regions
def update_diagnostics_regions(view: sublime.View, diagnostics: 'List[Diagnostic]', severity: int):
region_name = "code_intel_" + format_severity(severity)
if settings.show_diagnostics_phantoms and not view.is_dirty():
regions = None
else:
regions = list(range_to_region(diagnostic.range, view) for diagnostic in diagnostics
if diagnostic.severity == severity)
if regions:
scope_name = diagnostic_severity_scopes[severity]
view.add_regions(
region_name, regions, scope_name, settings.diagnostics_gutter_marker,
UNDERLINE_FLAGS if settings.diagnostics_highlight_style == "underline" else BOX_FLAGS)
else:
view.erase_regions(region_name)
示例14: left_enclosing_block
def left_enclosing_block(
view: sublime.View, point: int, scope: str, end: Optional[int] = None,
) -> Optional[Tuple[int, int]]:
"""
Like `enclosing_block`, but checks that `point` is the right-boundary of
the eventual block. If not, signal an error with `None`.
"""
if end is None:
end = view.size()
block = enclosing_block(view, point, scope, end=end)
if block and not view.match_selector(point + 1, scope):
return block
return None
示例15: on_pre_close
def on_pre_close(self, view: sublime.View) -> None:
"""Called when the view is about to be closed
"""
self._erase_marks(view)
for severity in ['VIOLATIONS', 'WARNINGS', 'ERRORS']:
ANACONDA[severity][view.id()] = {}