當前位置: 首頁>>代碼示例>>Python>>正文


Python sublime.ENCODED_POSITION屬性代碼示例

本文整理匯總了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) 
開發者ID:PhaserEditor2D,項目名稱:PhaserSublimePackage,代碼行數:21,代碼來源:tern.py

示例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 
開發者ID:fuse-open,項目名稱:Fuse.SublimePlugin,代碼行數:26,代碼來源:focus_editor.py

示例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) 
開發者ID:defuz,項目名稱:RustAutoComplete,代碼行數:18,代碼來源:RustAutoComplete.py

示例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
        ) 
開發者ID:tptee,項目名稱:FlowIDE,代碼行數:24,代碼來源:go_to_definition.py

示例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
        ) 
開發者ID:timbrel,項目名稱:GitSavvy,代碼行數:21,代碼來源:show_file_at_commit.py

示例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
            ) 
開發者ID:timbrel,項目名稱:GitSavvy,代碼行數:25,代碼來源:diff.py

示例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) 
開發者ID:niosus,項目名稱:EasyClangComplete,代碼行數:20,代碼來源:EasyClangComplete.py

示例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) 
開發者ID:OmniSharp,項目名稱:omnisharp-sublime,代碼行數:19,代碼來源:find_usages.py

示例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 
開發者ID:jcberquist,項目名稱:sublimetext-cfml,代碼行數:26,代碼來源:navigate_to_method.py

示例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) 
開發者ID:jcberquist,項目名稱:sublimetext-cfml,代碼行數:18,代碼來源:goto_cfml_file.py

示例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") 
開發者ID:Pegase745,項目名稱:sublime-flowtype,代碼行數:24,代碼來源:goto_definition.py

示例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) 
開發者ID:gerardroche,項目名稱:sublime-phpunit,代碼行數:8,代碼來源:plugin.py

示例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) 
開發者ID:fuse-open,項目名稱:Fuse.SublimePlugin,代碼行數:17,代碼來源:build_results.py

示例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 
開發者ID:fuse-open,項目名稱:Fuse.SublimePlugin,代碼行數:16,代碼來源:build_results.py

示例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) 
開發者ID:fuse-open,項目名稱:Fuse.SublimePlugin,代碼行數:12,代碼來源:go_to_definition.py


注:本文中的sublime.ENCODED_POSITION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。