zoukankan      html  css  js  c++  java
  • 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})

     7、得到选择区域的代码

            region = self.view.sel()[0]
            if region.empty():
                self.view.show_popup('empty')
                return
            tot_str = self.view.substr(region)
  • 相关阅读:
    第十周阅读内容
    第十周学习小结
    第九周阅读内容
    第九周学习小结
    第八周学习小结
    ..总结
    .总结
    总结.
    周总结
    总结
  • 原文地址:https://www.cnblogs.com/liuweimingcprogram/p/10957999.html
Copyright © 2011-2022 走看看