本文整理汇总了Python中sublime.ENCODED_POSITION属性的典型用法代码示例。如果您正苦于以下问题:Python sublime.ENCODED_POSITION属性的具体用法?Python sublime.ENCODED_POSITION怎么用?Python sublime.ENCODED_POSITION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sublime
的用法示例。
在下文中一共展示了sublime.ENCODED_POSITION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def run(self, edit, **args):
data = run_command(self.view, {"type": "definition", "lineCharPositions": True})
if data is None: return
file = data.get("file", None)
if file is not None:
# Found an actual definition
row, col = self.view.rowcol(self.view.sel()[0].b)
cur_pos = self.view.file_name() + ":" + str(row + 1) + ":" + str(col + 1)
jump_stack.append(cur_pos)
if len(jump_stack) > 50: jump_stack.pop(0)
real_file = (os.path.join(get_pfile(self.view).project.dir, file) +
":" + str(data["start"]["line"] + 1) + ":" + str(data["start"]["ch"] + 1))
sublime.active_window().open_file(real_file, sublime.ENCODED_POSITION)
else:
url = data.get("url", None)
if url is None:
sublime.error_message("Could not find a definition")
else:
webbrowser.open(url)
示例2: tryHandle
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def tryHandle(self, request):
if request.name != "FocusEditor":
return False
fileName = request.arguments["File"]
line = request.arguments["Line"]
column = request.arguments["Column"]
if not os.path.isfile(fileName):
self._returnFailure("File '{}' does not exist".format(fileName), request.id)
return True
window = self._tryGetWindowFor(request.arguments["Project"])
if window:
try:
window.open_file( "{}:{}:{}".format(fileName, line, column), sublime.ENCODED_POSITION)
if sublime.platform() == "osx":
self._focusWindowOSX()
self.msgManager.sendResponse(self.interop, request.id, "Success")
return True
elif sublime.platform() == "windows":
self.msgManager.sendResponse(self.interop, request.id, "Success", {"FocusHwnd":window.hwnd()})
return True
except Exception as e:
self._returnFailure(str(e), request.id)
return True
return False
示例3: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def run(self, edit):
# Get the buffer location in correct format for racer
row, col = self.view.rowcol(self.view.sel()[0].begin())
row += 1
results = run_racer(self.view, ["find-definition", str(row), str(col)])
if len(results) == 1:
result = results[0]
path = result.path
# On Windows the racer will return the paths without the drive
# letter and we need the letter for the open_file to work.
if sublime.platform() == 'windows' and not re.compile('^\w\:').match(path):
path = 'c:' + path
encoded_path = "{0}:{1}:{2}".format(path, result.row, result.column)
self.view.window().open_file(encoded_path, sublime.ENCODED_POSITION)
示例4: run_async
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def run_async(self):
result = None
try:
result = CLI(self.view).get_def()
except InvalidContext:
print('Invalid context')
pass
except Exception as e:
display_unknown_error(self.view, e)
return
print(result)
if not result or not result.get('path'):
return
sublime.active_window().open_file(
result['path'] +
':' + str(result['line']) +
':' + str(result['start']),
sublime.ENCODED_POSITION |
sublime.TRANSIENT
)
示例5: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def run(self, edit):
# type: (...) -> None
window = self.view.window()
if not window:
return
settings = self.view.settings()
commit_hash = settings.get("git_savvy.show_file_at_commit_view.commit")
file_path = settings.get("git_savvy.file_path")
assert commit_hash
assert file_path
full_path = os.path.join(self.repo_path, file_path)
row, col = self.view.rowcol(self.view.sel()[0].begin())
row = self.find_matching_lineno(commit_hash, None, row + 1, full_path)
window.open_file(
"{file}:{row}:{col}".format(file=full_path, row=row, col=col),
sublime.ENCODED_POSITION
)
示例6: load_file_at_line
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def load_file_at_line(self, commit_hash, filename, row, col):
# type: (Optional[str], str, int, int) -> None
"""
Show file at target commit if `git_savvy.diff_view.target_commit` is non-empty.
Otherwise, open the file directly.
"""
target_commit = commit_hash or self.view.settings().get("git_savvy.diff_view.target_commit")
full_path = os.path.join(self.repo_path, filename)
window = self.view.window()
if not window:
return
if target_commit:
window.run_command("gs_show_file_at_commit", {
"commit_hash": target_commit,
"filepath": full_path,
"lineno": row,
})
else:
window.open_file(
"{file}:{row}:{col}".format(file=full_path, row=row, col=col),
sublime.ENCODED_POSITION
)
示例7: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def run(self, edit):
"""Run goto declaration command.
Navigates to delcaration of entity located by current position
of cursor.
"""
if not SublBridge.is_valid_view(self.view):
return
config_manager = EasyClangComplete.view_config_manager
if not config_manager:
return
location = config_manager.trigger_get_declaration_location(self.view)
if location:
loc = location.file.name
loc += ":" + str(location.line)
loc += ":" + str(location.column)
log.debug("Navigating to declaration: %s", loc)
sublime.active_window().open_file(loc, sublime.ENCODED_POSITION)
示例8: _show_usages
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def _show_usages(self, data):
if data is None or data['QuickFixes'] is None:
return
usages = data["QuickFixes"]
items = [[u["Text"].strip(), u["FileName"] + " Line : " + str(u["Line"])] for u in usages]
window = sublime.active_window()
def on_done(i):
if i is not -1:
window.open_file('{}:{}:{}'.format(usages[i]["FileName"], usages[i]["Line"] or 0, usages[i]["Column"] or 0), sublime.ENCODED_POSITION)
def on_highlight(i):
if i is not -1:
window.open_file('{}:{}:{}'.format(usages[i]["FileName"], usages[i]["Line"] or 0, usages[i]["Column"] or 0), sublime.ENCODED_POSITION | sublime.TRANSIENT)
window.show_quick_panel(items, on_done, on_highlight=on_highlight)
示例9: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def run(self, file_path, href):
if len(file_path) > 0:
index_locations = self.window.lookup_symbol_in_index(href)
for full_path, project_path, rowcol in index_locations:
if utils.format_lookup_file_path(full_path) == file_path:
row, col = rowcol
self.window.open_file(full_path + ":" + str(row) + ":" + str(col), sublime.ENCODED_POSITION | sublime.FORCE_GROUP)
break
else:
# might be a setter, so for now just open the file
self.window.open_file(file_path)
else:
# this symbol should be in active view
view = self.window.active_view()
functions = view.find_by_selector("meta.function.declaration.cfml entity.name.function.cfml")
for funct_region in functions:
if view.substr(funct_region).lower() == href.lower():
view.sel().clear()
r = sublime.Region(funct_region.begin())
view.sel().add(r)
view.show(r)
break
示例10: open_file_at_symbol
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def open_file_at_symbol(view, file_path, symbol):
index_locations = view.window().lookup_symbol_in_index(symbol)
if file_path[1] == ":":
file_path = "/" + file_path[0] + file_path[2:]
for full_path, project_path, rowcol in index_locations:
if utils.format_lookup_file_path(full_path) == file_path:
row, col = rowcol
view.window().open_file(
full_path + ":" + str(row) + ":" + str(col),
sublime.ENCODED_POSITION | sublime.FORCE_GROUP,
)
break
else:
# if symbol can't be found in the index, go ahead and open the file
view.window().open_file(file_path)
示例11: handle_process
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def handle_process(self, returncode, stdout, error):
"""Handle the output from the threaded process."""
if type(error) is bytes:
error = error.decode("utf-8")
if returncode != 0:
logger.logger.error("get_def %s" % error)
return
logger.logger.debug(stdout)
if stdout and stdout["path"]:
self.active_window.open_file(
stdout["path"]
+ ":"
+ str(stdout["line"])
+ ":"
+ str(stdout["start"]),
sublime.ENCODED_POSITION | False,
)
else:
self.view.set_status("flow_type", "Flow: no definition found")
示例12: switch
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def switch(self):
def _on_switchable(switchable):
self.window.open_file(switchable.file_encoded_position(self.view), ENCODED_POSITION)
put_views_side_by_side(self.view, self.window.active_view())
find_switchable(self.view, on_select=_on_switchable)
示例13: run
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def run(self, edit):
view = self.view
window = view.window()
sel = view.sel()[0]
scope = view.scope_name(sel.a)
if scope.find(".name.") > -1:
scope = view.extract_scope(sel.a)
filePath = self.getPath(scope)
if filePath[0] == '':
return
window.open_file(filePath[0]+":"+str(filePath[1]), sublime.ENCODED_POSITION)
else:
self.openBasedOnNumericLine(window, view, sel)
示例14: openBasedOnNumericLine
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def openBasedOnNumericLine(self, window, view, sel):
foundSelLoc = self.findSelectionLocation(view, sel)
if foundSelLoc == None:
return
if foundRegion != None:
nameRegions = NameRegions(view)
for region in nameRegions:
if region.intersects(foundRegion):
scope = view.extract_scope(region.a+1)
filePath = self.getPath(scope)[0]
line = view.substr(foundSelLoc)
window.open_file(filePath+":" + line, sublime.ENCODED_POSITION)
break
示例15: gotoDefinition
# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import ENCODED_POSITION [as 别名]
def gotoDefinition(data):
window = sublime.active_window()
path = data["Path"]
caretPos = data["CaretPosition"]
line = int(caretPos["Line"])
column = int(caretPos["Character"])
openCommand = data["Path"] + ":" + str(line) + ":" + str(column)
view = window.open_file(openCommand, sublime.ENCODED_POSITION | sublime.TRANSIENT)