sublime text 开发记录贴

1、展示信息有两种:  

  self.view.show_popup('hello'), 这个好看点。
  sublime.status_message('ssss')    sublime.error_message('ssss')

    def __init__(self, view):
        self.view = view
        self.phantom_set = sublime.PhantomSet(view, 'git-blame')

2、在__init__的时候,self.veiw 

3、self.view.file_name()得到的是文件路径全名,配合subprocess中的cwd可以读取文件

4、一般这样得到当前鼠标的行和列

        for region in self.view.sel():
            line = self.view.line(region)
            (row, col) = self.view.rowcol(region.begin())
            full_path = self.view.file_name()

5、subprocess    git blame例子

    def get_blame(self, line, path):
        return subprocess.check_output(
            ["git", "blame", "--minimal", "-w", "-L {0},{0}".format(line), os.path.basename(path)],
            cwd=os.path.dirname(os.path.realpath(path)),
            startupinfo=si,
            stderr=subprocess.STDOUT
        ).decode("utf-8")

 6、创建一个文件并且写东西进去

                buf = self.view.window().new_file()
                buf.run_command('insert_commit_description', {'desc': desc, 'scratch_view_name': 'commit ' + sha})

猜你喜欢

转载自www.cnblogs.com/liuweimingcprogram/p/10957999.html
今日推荐