python类ENCODED_POSITION的实例源码

xmotions.py 文件源码 项目:VintageousPlus 作者: trishume 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def run(self, count=1, mode=None, globally=False):

        def f(view, s):
            if mode == modes.NORMAL:
                return sublime.Region(location, location)

            elif mode == modes.VISUAL:
                return sublime.Region(s.a + 1, location)

            elif mode == modes.INTERNAL_NORMAL:
                return sublime.Region(s.a, location)

            return s

        current_sel = self.view.sel()[0]
        self.view.sel().clear()
        self.view.sel().add(current_sel)

        location = self.find_symbol(current_sel, globally=globally)
        if not location:
            return

        if globally:
            # Global symbol; simply open the file; not a motion.
            # TODO: Perhaps must be a motion if the target file happens to be
            #       the current one?
            self.view.window().open_file(
                location[0] + ':' + ':'.join([str(x) for x in location[2]]),
                sublime.ENCODED_POSITION)
            return

        # Local symbol; select.
        location = self.view.text_point(*location)
        regions_transformer(self.view, f)
xactions.py 文件源码 项目:VintageousPlus 作者: trishume 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def run(self, edit, mode=None, character=None, count=1):
        def f(view, s):
            if mode == modes.VISUAL:
                if s.a <= s.b:
                    if address.b < s.b:
                        return R(s.a + 1, address.b)
                    else:
                        return R(s.a, address.b)
                else:
                    return R(s.a + 1, address.b)

            elif mode == modes.NORMAL:
                return address

            elif mode == modes.INTERNAL_NORMAL:
                if s.a < address.a:
                    return R(view.full_line(s.b).a,
                                          view.line(address.b).b)
                return R(view.full_line(s.b).b,
                                      view.line(address.b).a)

            return s

        state = self.state
        address = state.marks.get_as_encoded_address(character)

        if address is None:
            return

        if isinstance(address, str):
            if not address.startswith('<command'):
                self.view.window().open_file(address, sublime.ENCODED_POSITION)
            else:
                # We get a command in this form: <command _vi_double_quote>
                self.view.run_command(address.split(' ')[1][:-1])
            return

        regions_transformer(self.view, f)

        if not self.view.visible_region().intersects(address):
            self.view.show_at_center(address)
xactions.py 文件源码 项目:VintageousPlus 作者: trishume 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def run(self, edit, count=1, mode=None, character=None):
        def f(view, s):
            if mode == modes.VISUAL:
                if s.a <= s.b:
                    if address.b < s.b:
                        return R(s.a + 1, address.b)
                    else:
                        return R(s.a, address.b)
                else:
                    return R(s.a + 1, address.b)
            elif mode == modes.NORMAL:
                return address
            elif mode == modes.INTERNAL_NORMAL:
                return R(s.a, address.b)

            return s

        state = self.state
        address = state.marks.get_as_encoded_address(character, exact=True)

        if address is None:
            return

        if isinstance(address, str):
            if not address.startswith('<command'):
                self.view.window().open_file(address, sublime.ENCODED_POSITION)
            return

        # This is a motion in a composite command.
        regions_transformer(self.view, f)
open_file_from_text.py 文件源码 项目:st-user-package 作者: math2001 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def on_found(self, path, line):
        self.window.open_file(path + ':' + line, sublime.ENCODED_POSITION)
debug.py 文件源码 项目:SublimeAnarchyDebug 作者: AnarchyTools 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def update_run_marker(window, lldb=None):
    if not lldb:
        for view in window.views():
            view.erase_regions("run_pointer")
        return

    with retry():
        try:
            bt = lldb.get_backtrace_for_selected_thread()
            if 'bt' not in bt:
                for view in window.views():
                    view.erase_regions("run_pointer")
                return
            for frame in bt['bt']:
                if 'file' in frame and frame['line'] != 0:
                    found = False
                    for view in window.views():
                        if view.file_name() == frame['file']:
                            location = view.line(view.text_point(frame['line'] - 1, 0))
                            view.add_regions("run_pointer", [location], "entity.name.class", "Packages/SublimeAnarchyDebug/images/stop_point.png", sublime.DRAW_NO_FILL)
                            if not view.visible_region().contains(location):
                                view.show_at_center(location)
                            if window.active_group() == 0:
                                window.focus_view(view)
                            found = True
                    if not found:
                        grp = window.active_group()
                        window.focus_group(0)
                        view = window.open_file(frame['file'] + ":" + str(frame['line']), sublime.ENCODED_POSITION)
                        window.focus_group(grp)
                        location = view.line(view.text_point(frame['line'] - 1, 0))
                        view.add_regions("run_pointer", [location], "entity.name.class", "Packages/SublimeAnarchyDebug/images/stop_point.png", sublime.DRAW_NO_FILL)
                        if not view.visible_region().contains(location):
                            view.show_at_center(location)
                    break
        except xmlrpc.client.Fault:
            for view in window.views():
                view.erase_regions("run_pointer")
SourcetrailPlugin.py 文件源码 项目:sublime-sourcetrail 作者: CoatiSoftware 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def setCursorPosition(filePath, row, col):
    if (os.path.exists(filePath)):
        sublime.active_window().open_file(filePath + ":" + str(row) +
                                          ":" + str(col), sublime.ENCODED_POSITION)
    else:
        sublime.error_message(
            "Sourcetrail is trying to jump to a file that does not exist: " + filePath)
RemoteCpp.py 文件源码 项目:RemoteCpp 作者: ruibm 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _open_file(self, window, file):
      self.log('rui => ' + str(file.to_args()))
      path_row_col = '{path}:{row}:{col}'.format(
          path=file.local_path(),
          row=file.row,
          col=file.col)
      view = window.open_file(path_row_col, sublime.ENCODED_POSITION)
new_script.py 文件源码 项目:Sublime-GameMaker-Studio-Language-Bundle 作者: uduse 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def make_script(self, project_info_path, script_dir_path, script_name):
        with open(project_info_path, "r+", encoding="utf-8-sig") as f:
            try:
                # Generate script parameters
                script_key = str(uuid.uuid4())
                script_id = str(uuid.uuid4())
                info = json.load(f, object_pairs_hook=OrderedDict)

                # TODO: check if dir or script exisits already

                # Insert the new script into the project info file
                resource_path = "scripts\\%s\\%s.yy" % (script_name, script_name)
                new_resource_item = OrderedDict(
                    [("Key", script_key),
                     ("Value", OrderedDict(
                            [("id", script_id),
                            ("resourcePath", resource_path),
                            ("resourceType", "GMScript")]
                        ))
                    ])
                info['resources'].insert(0, new_resource_item)
                info['script_order'].append(script_key)
                f.seek(0)
                f.write(json.dumps(info, separators=(',', ': '), indent=4))
                f.truncate()

                os.chdir(script_dir_path)
                os.mkdir(script_name)
                os.chdir(script_dir_path + "/" + script_name)

                # Generate script file and open for edit
                with open(script_name + ".gml", "w", encoding="utf-8-sig") as f:
                    window = self.view.window()
                    view = window.open_file(script_dir_path + "/" + 
                        script_name + "/" + script_name + ".gml", sublime.ENCODED_POSITION)
                    window.focus_view(view)

                # Generate and fills the script info file
                with open(script_name + ".yy", "w", encoding="utf-8-sig") as f:
                    info = OrderedDict(
                        [("id", script_key),
                        ("modelName", "GMScript"),
                        ("mvc", "1.0"),
                        ("name", script_name),
                        ("IsCompatibility", False),
                        ("IsDnD", False)
                        ])
                    json.dump(info, f, separators=(',', ': '), indent=4)
            except Exception as e:
                print(e)
sublimegdb.py 文件源码 项目:SublimeRemoteGDB 作者: summerwinter 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def update_cursor():
    global gdb_cursor
    global gdb_cursor_position
    global gdb_stack_index
    global gdb_stack_frame

    if not get_setting("update_while_running", True) and gdb_run_status == "running":
        return

    res = run_cmd("-stack-info-frame", True)
    if get_result(res) == "error":
        if gdb_run_status != "running":
            print("run_status is %s, but got error: %s" % (gdb_run_status, res))
            return
    currFrame = parse_result_line(res)["frame"]
    gdb_stack_index = int(currFrame["level"])

    if "fullname" in currFrame:
        gdb_cursor = gdb_source_path.translate_remote_path(currFrame["fullname"])
        gdb_cursor_position = int(currFrame["line"])
        sublime.active_window().focus_group(get_setting("file_group", 0))
        sublime.active_window().open_file("%s:%d" % (gdb_cursor, gdb_cursor_position), sublime.ENCODED_POSITION)
        global gdb_global_command_input_focused
        if gdb_global_command_input_focused == True:
            sublime.active_window().focus_view(gdb_input_view)
            gdb_global_command_input_focused = False
    else:
        gdb_cursor_position = 0

    sameFrame = gdb_stack_frame is not None and \
                gdb_stack_frame["func"] == currFrame["func"]
    if sameFrame and "shlibname" in currFrame and "shlibname" in gdb_stack_frame:
        sameFrame = currFrame["shlibname"] == gdb_stack_frame["shlibname"]
    if sameFrame and "fullname" in currFrame and "fullname" in gdb_stack_frame:
        sameFrame = currFrame["fullname"] == gdb_stack_frame["fullname"]

    gdb_stack_frame = currFrame
    # Always need to update the callstack since it's possible to
    # end up in the current function from many different call stacks
    gdb_callstack_view.update_callstack()
    gdb_threads_view.update_threads()

    update_view_markers()
    gdb_variables_view.update_variables(sameFrame)
    gdb_register_view.update_values()
    gdb_disassembly_view.update_disassembly()

    global gdb_first_callstack
    if gdb_first_callstack == False and gdb_settings.get("debug_mode") in ["attach", "coredump"]:
        gdb_first_callstack = True
        gdb_breakpoint_view.sync_breakpoints()
CrystalAutoComplete.py 文件源码 项目:CrystalAutoComplete 作者: TechMagister 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def on_query_completions(self, view, prefix, locations):
        # Check if this is a Crystal source file. This check
        # relies on the Crystal syntax formatting extension
        # being installed - https://github.com/crystal-lang/sublime-crystal
        if view.match_selector(locations[0], "source.crystal"):

            try:
                raw_results = run_cracker(view, locations[0])
            except FileNotFoundError:
                print("Unable to find cracker executable (check settings)")
                return

            results = []
            regexp = '[\.#](.+)\('

            for r in raw_results:
                if r.type == "Function":
                    if r.name.find("#") != -1:
                        trigger = r.name.split("#")[1]
                    else:
                        trigger = r.name.split(".")[1]
                    contents = trigger.split("(")[0]

                    if r.name.find("()") == -1:
                        contents = contents + '('
                else:
                    trigger = r.name
                    contents = r.name
                results.append([trigger, contents])

            if len(results) > 0:
                # return results
                return (results, sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS)


#class CrystalGotoDefinitionCommand(sublime_plugin.TextCommand):
#    def run(self, edit):
#        # Get the buffer location in correct format for cracker
#        row, col = self.view.rowcol(self.view.sel()[0].begin())
#        row += 1
#
#        results = run_cracker(self.view, ["find-definition", str(row), str(col)])
#
#        if len(results) == 1:
#            result = results[0]
#            path = result.path
#            # On Windows the cracker 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)


问题


面经


文章

微信
公众号

扫码关注公众号