本文整理汇总了Python中sublime.COOPERATE_WITH_AUTO_COMPLETE属性的典型用法代码示例。如果您正苦于以下问题:Python sublime.COOPERATE_WITH_AUTO_COMPLETE属性的具体用法?Python sublime.COOPERATE_WITH_AUTO_COMPLETE怎么用?Python sublime.COOPERATE_WITH_AUTO_COMPLETE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sublime
的用法示例。
在下文中一共展示了sublime.COOPERATE_WITH_AUTO_COMPLETE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def __init__(self, component: Union[span, div], view: sublime.View, location: int = -1, on_close: Optional[Callable[[], None]] = None) -> None:
super().__init__(component, view)
self.on_close = on_close
self.location = location
self.max_height = 500
self.max_width = 1000
self.render()
view.show_popup(
self.html,
location=location,
max_width=self.max_width,
max_height=self.max_height,
on_navigate=self.on_navigate,
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HIDE_ON_MOUSE_MOVE_AWAY,
on_hide=self.on_hide
)
_renderables_add.append(self)
self.is_hidden = False
示例2: run_async
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def run_async(self, pkg, funct, point=-1):
if not funct:
pkg, funct = self.function_name_at_point(self.view, point)
if not pkg:
pkg = namespace_manager.find_object_in_packages(funct)
funct_call = namespace_manager.get_function_call(pkg, funct)
if not funct_call:
return
with preference_temporary_settings("mdpopups.use_sublime_highlighter",
True):
with preference_temporary_settings(
"mdpopups.sublime_user_lang_map",
{"s": [["r"], ["R/R.sublime-syntax"]]}):
text = POPUP_TEMPLATE.format(
mdpopups.syntax_highlight(
self.view, funct_call.strip(), language="r"), pkg,
funct)
mdpopups.show_popup(
self.view,
text,
css=POPUP_CSS,
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HIDE_ON_MOUSE_MOVE_AWAY,
location=point,
max_width=800,
on_navigate=lambda x: self.on_navigate(x, pkg, funct, point))
示例3: show
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def show(view, marker, as_phantom=False):
"Displays Emmet abbreviation as a preview for given view"
content = None
buffer_id = view.buffer_id()
try:
content = format_snippet(marker.preview())
except Exception as e:
content = '<div class="error">%s</div>' % format_snippet(str(e))
if content:
if as_phantom:
if buffer_id not in phantom_sets_by_buffer:
phantom_set = sublime.PhantomSet(view, 'emmet')
phantom_sets_by_buffer[buffer_id] = phantom_set
else:
phantom_set = phantom_sets_by_buffer[buffer_id]
r = sublime.Region(marker.region.end(), marker.region.end())
phantoms = [sublime.Phantom(r, phantom_content(content), sublime.LAYOUT_INLINE)]
phantom_set.update(phantoms)
elif not view.is_popup_visible() or previews_by_buffer.get(buffer_id, None) != marker.abbreviation:
previews_by_buffer[buffer_id] = marker.abbreviation
view.show_popup(popup_content(content), sublime.COOPERATE_WITH_AUTO_COMPLETE, marker.region.begin(), 400, 300)
示例4: my_show_popup
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def my_show_popup(view, content, location, markdown=None):
global GLOBAL_IGNORE_EVENTS
GLOBAL_IGNORE_EVENTS = True
if markdown is None:
view.show_popup(
content,
sublime.COOPERATE_WITH_AUTO_COMPLETE,
location=location,
max_width=1500,
max_height=1200,
on_navigate=webbrowser.open,
)
else:
content = escape(content)
view.show_popup(
content,
sublime.COOPERATE_WITH_AUTO_COMPLETE,
location=location,
max_width=1500,
max_height=1200,
on_navigate=webbrowser.open,
)
GLOBAL_IGNORE_EVENTS = False
示例5: show_popup
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def show_popup(self, symbol, symbolDescription):
output = symbolDescription
if getSetting('debug'):
print(output)
self.currentSymbol = symbol
width, height = self.view.viewport_extent()
output = self.formatPopup(output, symbol=symbol)
# It seems sublime will core when the output is too long
# In some cases the value can set to 76200, but we use a 65535 for safety.
output = output[:65535]
self.view.show_popup(
output,
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HTML,
location=-1,
max_width=min(getSetting('popup_max_width'), width),
max_height=min(getSetting('popup_max_height'), height - 100),
on_navigate=self.on_navigate,
on_hide=self.on_hide
)
示例6: _render_impl
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def _render_impl(self, pfile, view, message):
view.show_popup(message, sublime.COOPERATE_WITH_AUTO_COMPLETE,
max_width=600, on_navigate=go_to_url)
示例7: _update_popup
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def _update_popup(self, content, location):
if content:
if self.view.is_popup_visible():
self.view.update_popup(content)
else:
self.view.show_popup(
content,
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
location=location,
max_width=20000,
max_height=20000,
)
示例8: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def run(self, edit, event=None, symbol=None, force=False):
global language, currentView
view = self.view
currentView = view
pt = False
language = getSetting('language')
if not language:
view.window().run_command('docphp_checkout_language')
return
if symbol == None:
if event:
pt = view.window_to_text((event["x"], event["y"]))
else:
pt = view.sel()[0]
self.pt = pt
symbol, locations = sublime_symbol.symbol_at_point(view, pt)
translatedSymbol = symbol.replace('_', '-')
# symbol = 'basename'
translatedSymbol, symbolDescription = getSymbolDescription(translatedSymbol)
if not symbolDescription:
if getSetting('prompt_when_not_found'):
view.show_popup('not found', sublime.COOPERATE_WITH_AUTO_COMPLETE)
return
return
if getSetting('use_panel') == False:
self.show_popup(translatedSymbol, symbolDescription)
else:
self.show_panel(translatedSymbol, symbolDescription, edit)
示例9: display_documentation
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def display_documentation(view, docs, doc_type, pt=-1, current_index=0):
global doc_window
doc_region_id = str(uuid.uuid4())
doc_html, doc_regions = generate_documentation(view, docs, current_index, doc_type)
on_navigate = get_on_navigate(view, docs, doc_type, current_index, pt)
if doc_type == "completion_doc":
if doc_window and doc_window == "completion_doc":
view.update_popup(doc_html)
else:
doc_window = "completion_doc"
view.show_popup(
doc_html,
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
max_width=480,
on_navigate=on_navigate,
on_hide=lambda: on_hide(view, doc_region_id),
)
else:
if doc_regions and utils.get_setting("inline_doc_regions_highlight"):
view.add_regions(
doc_region_id,
merge_regions(doc_regions),
"source",
flags=sublime.DRAW_NO_FILL,
)
doc_window = "inline_doc"
flags = sublime.HIDE_ON_MOUSE_MOVE_AWAY if doc_type == "hover_doc" else 0
# print(doc_html)
view.show_popup(
doc_html,
location=pt,
flags=flags,
max_width=768,
max_height=480,
on_navigate=on_navigate,
on_hide=lambda: on_hide(view, doc_region_id),
)
示例10: hint_popup
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def hint_popup(self, location, completions):
html = ""
for completion in completions :
parameters_html = "()"
completion_class_name = completion[0].split("\t")[1].strip()
if len(completion_class_name) > 15 :
completion_class_name = completion_class_name[0:15] + ".."
completion_description = completion[1]
if completion_description.get("type") == "operation" :
parameters = []
for parameter in completion_description.get("parameters") :
parameters.append( "<span class=\"parameter-name\">" + parameter.get("name") + "</span>" + ( "<span class=\"parameter-is-optional\">?</span>" if parameter.get("is_optional") else "" ) + "<span class=\"parameter-symbol\">:</span> " + "<span class=\"parameter-type\">" + parameter.get("type") + "</span>" )
if len(parameters) > 0 :
parameters_html = "( " + ", ".join(parameters) + " )"
html += """
<div class=\"container-description\">
<div><span class=\"operation-class-name\">"""+completion_class_name+""" <span class=\"circle\">F</span></span><div class=\"container-info\"><span class=\"operation-name\">"""+completion_description.get("name")+"</span>"+parameters_html+""" : <span class=\"operation-return-type\">"""+completion_description.get("return_type")+"""</span></div></div>
<div class=\"container-url-doc\"><a href=\""""+completion[2]+"""\">View complete doc</a> <span class=\"label\">URL doc: </span><a class=\"operation-url-doc-link\" href=\""""+completion_description.get("url_doc")+"""\">"""+completion_description.get("url_doc")+"""</a></div>
</div>
"""
elif completion_description.get("type") == "property" :
html += """
<div class=\"container-description\">
<div><span class=\"property-class-name\">"""+completion_class_name+""" <span class=\"circle\">P</span></span><div class=\"container-info\"><span class=\"property-name\">"""+completion_description.get("name")+"</span>"+" : <span class=\"property-return-type\">"""+completion_description.get("return_type")+"""</span></div></div>
<div class=\"container-url-doc\"><a href=\""""+completion[2]+"""\">View complete doc</a> <span class=\"label\">URL doc: </span><a class=\"property-url-doc-link\" href=\""""+completion_description.get("url_doc")+"""\">"""+completion_description.get("url_doc")+"""</a></div>
</div>
"""
elif completion_description.get("type") == "constructor" :
parameters = []
for parameter in completion_description.get("parameters") :
parameters.append( "<span class=\"parameter-name\">" + parameter.get("name") + "</span>" + ( "<span class=\"parameter-is-optional\">?</span>" if parameter.get("is_optional") else "" ) + "<span class=\"parameter-symbol\">:</span> " + "<span class=\"parameter-type\">" + parameter.get("type") + "</span>" )
if len(parameters) > 0 :
parameters_html = "( " + ", ".join(parameters) + " )"
html += """
<div class=\"container-description\">
<div><span class=\"constructor-class-name\">"""+completion_class_name+""" <span class=\"circle\">C</span></span><div class=\"container-info\"><span class=\"constructor-name\">"""+completion_description.get("name")+"</span>"+parameters_html+""" : <span class=\"constructor-return-type\">"""+completion_description.get("return_type")+"""</span></div></div>
<div class=\"container-url-doc\"><a href=\""""+completion[2]+"""\">View complete doc</a> <span class=\"label\">URL doc: </span><a class=\"constructor-url-doc-link\" href=\""""+completion_description.get("url_doc")+"""\">"""+completion_description.get("url_doc")+"""</a></div>
</div>
"""
sublime.active_window().active_view().show_popup("""
<html><head></head><body>
"""+js_css+"""
<div class=\"container-hint-popup\">
""" + html + """
</div>
</body></html>""", sublime.COOPERATE_WITH_AUTO_COMPLETE | sublime.HIDE_ON_MOUSE_MOVE_AWAY, location, 1150, 60, open_browser)
示例11: find_descriptionclick
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def find_descriptionclick(href, location=-1, is_single=False):
global javascriptCompletions
global popup_is_showing
href = href.split(",")
completion_description = javascriptCompletions.api[href[0]].get('completions')[int(href[1])][1]
class_name = javascriptCompletions.api[href[0]].get('completions')[int(href[1])][0].split("\t")[1]
sublime.active_window().active_view().hide_popup()
html = ""
parameters_html = "()"
if completion_description.get("type") == "operation" :
parameters = []
for parameter in completion_description.get("parameters") :
parameters.append( "<span class=\"parameter-name\">" + parameter.get("name") + "</span>" + ( "<span class=\"parameter-is-optional\">?</span>" if parameter.get("is_optional") else "" ) + "<span class=\"parameter-symbol\">:</span> " + "<span class=\"parameter-type\">" + parameter.get("type") + "</span>" )
if len(parameters) > 0 :
parameters_html = "( " + ", ".join(parameters) + " )"
html = """
<div class=\"container-description\">
<p><div class=\"label\">Syntax:</div><span class=\"operation-name\">"""+completion_description.get("name")+"</span>"+parameters_html+(" : <span class=\"operation-is-static\">static</span>" if completion_description.get("is_static") else "")+"""</p>
<p><div class=\"label\">Return Type:</div><span class=\"operation-return-type\">"""+completion_description.get("return_type")+"""</span></p>
<p><div class=\"label\">Description:</div><span class=\"operation-description\">"""+completion_description.get("description")+"""</span></p>
<p><div class=\"label\">URL doc:</div><a class=\"operation-url-doc-link\" href=\""""+completion_description.get("url_doc")+"""\">"""+completion_description.get("url_doc")+"""</a></p>
</div>
"""
elif completion_description.get("type") == "property" :
html = """
<div class=\"container-description\">
<p><div class=\"label\">Syntax:</div><span class=\"property-name\">"""+completion_description.get("name")+"""</span>"""+(" : <span class=\"property-is-static\">static</span>" if completion_description.get("is_static") else "")+"""</p>
<p><div class=\"label\">Return Type:</div><span class=\"property-return-type\">"""+completion_description.get("return_type")+"""</span></p>
<p><div class=\"label\">Description:</div><span class=\"property-description\">"""+completion_description.get("description")+"""</span></p>
<p><div class=\"label\">URL doc:</div><a class=\"property-url-doc-link\" href=\""""+completion_description.get("url_doc")+"""\">"""+completion_description.get("url_doc")+"""</a></p>
</div>
"""
elif completion_description.get("type") == "constructor" :
parameters = []
for parameter in completion_description.get("parameters") :
parameters.append( "<span class=\"parameter-name\">" + parameter.get("name") + "</span>" + ( "<span class=\"parameter-is-optional\">?</span>" if parameter.get("is_optional") else "" ) + "<span class=\"parameter-symbol\">:</span> " + "<span class=\"parameter-type\">" + parameter.get("type") + "</span>" )
if len(parameters) > 0 :
parameters_html = "( " + ", ".join(parameters) + " )"
html = """
<div class=\"container-description\">
<p><div class=\"label\">Syntax:</div><span class=\"constructor-name\">"""+completion_description.get("name")+"</span>"+parameters_html+"""</p>
<p><div class=\"label\">Return Type:</div><span class=\"constructor-return-type\">"""+completion_description.get("return_type")+"""</span></p>
<p><div class=\"label\">Description:</div><span class=\"constructor-description\">"""+completion_description.get("description")+"""</span></p>
<p><div class=\"label\">URL doc:</div><a class=\"constructor-url-doc-link\" href=\""""+completion_description.get("url_doc")+"""\">"""+completion_description.get("url_doc")+"""</a></p>
</div>
"""
popup_is_showing = True
sublime.active_window().active_view().show_popup("""
<html><head></head><body>
"""+js_css+"""
<div class=\"container\">
""" + ("<a class=\"back-button\" href=\"back\">Back to the list</a>" if not is_single else "") + """
<h3 class=\"class-name\">"""+class_name+"""</h3>
""" + html + """
</div>
</body></html>""", sublime.COOPERATE_WITH_AUTO_COMPLETE, location, 1000, 500, back_to_list_find_description)
示例12: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def run(self, edit, is_line=False, eval_type="eval"):
global result_js
global region_selected
global popup_is_showing
view = self.view
sel = view.sel()[0]
popup_is_showing = False
str_selected = view.substr(sel).strip()
if is_line:
lines = view.lines(sel)
region_selected = lines[0]
str_selected = view.substr(region_selected)
else:
if not str_selected and region_selected :
region = get_start_end_code_highlights_eval()
region_selected = sublime.Region(region[0], region[1])
lines = view.lines(region_selected)
str_selected = ""
for line in lines:
str_selected += view.substr(view.full_line(line))
elif str_selected:
lines = view.lines(sel)
region_selected = sublime.Region if not region_selected else region_selected
region_selected = sublime.Region(lines[0].begin(), lines[-1:][0].end())
elif not str_selected :
return
if not region_selected :
return
view.run_command("show_start_end_dot_eval")
try:
from node.main import NodeJS
node = NodeJS()
result_js = node.eval(str_selected, eval_type, True)
popup_is_showing = True
view.show_popup("<html><head></head><body>"+ej_css+"""<div class=\"container\">
<p class="result">Result: """+result_js+"""</p>
<div><a href="view_result_formatted">View result formatted(\\t,\\n,...)</a></div>
<div><a href="copy_to_clipboard">Copy result to clipboard</a></div>
<div><a href="replace_text">Replace text with result</a></div>
</div>
</body></html>""", sublime.COOPERATE_WITH_AUTO_COMPLETE, -1, 400, 400, action_result)
except Exception as e:
#sublime.error_message("Error: "+traceback.format_exc())
sublime.active_window().show_input_panel("Result", "Error: "+traceback.format_exc(), lambda x: "" , lambda x: "", lambda : "")
示例13: show_preview
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def show_preview(self, view: sublime.View, as_phantom=None):
"Displays expanded preview of abbreviation in current tracker in given view"
if not emmet.get_settings('abbreviation_preview', True):
return
content = None
if as_phantom is None:
# By default, display preview for CSS abbreviation as phantom to not
# interfere with default autocomplete popup
as_phantom = self.config and self.config['type'] == 'stylesheet'
if not self.abbreviation:
# No parsed abbreviation: empty region
pass
if 'error' in self.abbreviation:
# Display error snippet
err = self.abbreviation['error']
snippet = html.escape( re.sub(r'\s+at\s\d+$', '', err['message']), False)
content = '<div class="error pointer">%s</div><div class="error message">%s</div>' % (err['pointer'], snippet)
elif self.forced or as_phantom or not self.abbreviation['simple']:
snippet = self.abbreviation['preview']
if self.config['type'] != 'stylesheet':
if syntax.is_html(self.config['syntax']):
snippet = html_highlight.highlight(snippet)
else:
snippet = html.escape(snippet, False)
content = '<div class="markup-preview">%s</div>' % format_snippet(snippet)
else:
content = format_snippet(snippet)
if not content:
self.hide_preview(view)
return
if as_phantom:
if not self._phantom_preview:
self._phantom_preview = sublime.PhantomSet(view, ABBR_PREVIEW_ID)
r = sublime.Region(self.region.end(), self.region.end())
phantoms = [sublime.Phantom(r, preview_phantom_html(content), sublime.LAYOUT_INLINE)]
self._phantom_preview.update(phantoms)
else:
self._has_popup_preview = True
view.show_popup(
preview_popup_html(content),
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
location=self.region.begin(),
max_width=400,
max_height=300)
示例14: show_preview
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def show_preview(editor: sublime.View, tracker: AbbreviationTracker):
"Displays expanded preview of abbreviation in current tracker in given view"
if not get_settings('abbreviation_preview', True):
return
key = editor.id()
content = None
as_phantom = tracker.config.type == 'stylesheet'
if isinstance(tracker, AbbreviationTrackerError):
# Display error snippet
err = tracker.error
snippet = html.escape( re.sub(r'\s+at\s\d+$', '', err['message']), False)
content = '<div class="error pointer">%s</div><div class="error message">%s</div>' % (err['pointer'], snippet)
elif isinstance(tracker, AbbreviationTrackerValid) and tracker.abbreviation and (tracker.forced or as_phantom or not tracker.simple):
snippet = tracker.preview
if tracker.config.type != 'stylesheet':
if syntax.is_html(tracker.config.syntax):
snippet = html_highlight.highlight(snippet)
else:
snippet = html.escape(snippet, False)
content = '<div class="markup-preview">%s</div>' % format_snippet(snippet)
else:
content = format_snippet(snippet)
if not content:
hide_preview(editor)
return
if as_phantom:
pos = tracker.region.end()
r = sublime.Region(pos, pos)
phantoms = [sublime.Phantom(r, preview_phantom_html(content), sublime.LAYOUT_INLINE)]
if key not in _phantom_preview:
_phantom_preview[key] = sublime.PhantomSet(editor, ABBR_PREVIEW_ID)
_phantom_preview[key].update(phantoms)
else:
_has_popup_preview[key] = True
editor.show_popup(
preview_popup_html(content),
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
location=tracker.region.begin(),
max_width=400,
max_height=300)
示例15: show_colors
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import COOPERATE_WITH_AUTO_COMPLETE [as 别名]
def show_colors(self, palette_type, palette_name, delete=False, update=False):
"""Show colors under the given palette."""
target = None
current = False
if palette_type == "__special__":
if palette_name == "Current Colors":
current = True
target = {
"name": palette_name,
"colors": self.view.settings().get('color_helper.file_palette', [])
}
elif palette_name == "Favorites":
target = util.get_favs()
elif palette_type == "__global__":
for palette in util.get_palettes():
if palette_name == palette['name']:
target = palette
elif palette_type == "__project__":
for palette in util.get_project_palettes(self.view.window()):
if palette_name == palette['name']:
target = palette
if target is not None:
template_vars = {
"delete": delete,
'show_delete_menu': not delete and not current,
"back": '__colors__' if delete else '__palettes__',
"palette_type": palette_type,
"palette_name": target["name"],
"colors": self.format_colors(target['colors'], target['name'], palette_type, delete)
}
if update:
mdpopups.update_popup(
self.view,
sublime.load_resource('Packages/ColorHelper/panels/colors.html'),
wrapper_class="color-helper content",
css=util.ADD_CSS,
template_vars=template_vars,
nl2br=False
)
else:
self.view.settings().set('color_helper.popup_active', True)
self.view.settings().set('color_helper.popup_auto', self.auto)
mdpopups.show_popup(
self.view,
sublime.load_resource('Packages/ColorHelper/panels/colors.html'),
wrapper_class="color-helper content",
css=util.ADD_CSS, location=-1, max_width=1024, max_height=512,
on_navigate=self.on_navigate,
on_hide=self.on_hide,
flags=sublime.COOPERATE_WITH_AUTO_COMPLETE,
template_vars=template_vars,
nl2br=False
)