예제 #1
0
 def view_pdf(self):
     if not Shell.isinPATH('pdftoppm'):
         self.view_mime()
     else:
         if self.path not in self.tempfile_cache:
             fname = tempfile.mkstemp()[1]
             Shell.touch(fname)
             self.tempfile_cache[self.path] = fname
         fname = self.tempfile_cache[self.path]
         Shell.run(f'pdftoppm -png -f 1 -singlefile "{self.path}" {fname}')
         self.path = self.tempfile_cache[self.path] + '.png'
         self.view_image()
예제 #2
0
파일: fs.py 프로젝트: ipod825/vim-netranger
    def list_remotes_in_vim_buffer(self):
        if not Shell.isinPATH('rclone'):
            self.install_rclone()

        remotes = set(self.cmd_listremotes())
        local_remotes = set(super(Rclone, self).ls(self.root_dir))
        for remote in remotes.difference(local_remotes):
            Shell.mkdir(os.path.join(self.root_dir, remote))
        for remote in local_remotes.difference(remotes):
            Shell.rm(os.path.join(self.root_dir, remote))

        if len(remotes) > 0:
            Vim.command(f'NETRTabdrop {self.root_dir}')
        else:
            Vim.ErrorMsg(
                "There's no remote now. Run 'rclone config' in a terminal to "
                "setup remotes and restart vim again.")
예제 #3
0
 def view_image(self):
     try:
         import ueberzug
     except ModuleNotFoundError:
         Vim.ErrorMsg('Please install ueberzug for image preview')
         self.view_mime()
         return
     path = self.path
     if self.path.endswith('gif') and Shell.isinPATH('convert'):
         if self.path not in self.tempfile_cache:
             dir = tempfile.TemporaryDirectory().name
             Shell.mkdir(dir)
             self.tempfile_cache[self.path] = dir
         dir = self.tempfile_cache[self.path]
         path = dir
         Shell.run(f'convert -deconstruct  "{self.path}" {dir}/a.png')
     Vim.AsyncRun(f'{util.GenNetRangerScriptCmd("image_preview")}\
                     "{path}" {self.total_width} {self.preview_width}',
                  term=True,
                  termopencmd='')
     Vim.command('setlocal nocursorline')
예제 #4
0
파일: rifle.py 프로젝트: xbl3/vim-netranger
 def __call__(self, fname):
     return Shell.isinPATH(self.args[0])