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)
既然选择了远方,就要风雨兼程~
posted on 2019-05-31 23:20 stupid_one 阅读(224) 评论(0) 编辑 收藏 举报