コード例 #1
0
ファイル: ui.py プロジェクト: xbl3/vim-netranger
 def load_bookmarks(self):
     self.mark_dict = {}
     if os.path.isfile(Vim.Var('NETRBookmarkFile')):
         with open(Vim.Var('NETRBookmarkFile'), 'r') as f:
             for line in f:
                 kp = line.split(':')
                 if (len(kp) == 2):
                     self.mark_dict[kp[0].strip()] = kp[1].strip()
コード例 #2
0
ファイル: fs.py プロジェクト: ipod825/vim-netranger
    def init(self, root_dir, remote_remap):
        self._flags = Vim.Var("_NETRRcloneFlags", default="")
        self.rclone_rcd_port = Vim.Var('NETRcloneRcdPort')
        if root_dir[-1] == '/':
            root_dir = root_dir[:-1]

        self.root_dir = root_dir
        self.rplen = len(root_dir) + 1
        self.rcd_started = False
        for remote, root in remote_remap.items():
            if root[-1] != '/':
                remote_remap[remote] += '/'
        self.remote_remap = remote_remap
        Shell.mkdir(root_dir)
コード例 #3
0
ファイル: ui.py プロジェクト: xbl3/vim-netranger
    def _set(self, mark):
        """ The callback for the BookMarkUI/set. """
        if mark == '':
            return
        if mark not in self.valid_mark:
            Vim.command('echo "Only a-zA-Z are valid mark!!"')
            return
        set_buf = self.bufs['set']
        set_buf.options['modifiable'] = True

        if mark in self.mark_dict:
            for i, line in enumerate(set_buf):
                if len(line) > 0 and line[0] == mark:
                    set_buf[i] = f'{mark}:{self.path_to_mark}'
                    break
        elif self.path_to_mark in self.mark_dict.values():
            for i, line in enumerate(set_buf):
                if len(line) > 0 and line[2:] == self.path_to_mark:
                    set_buf[i] = f'{mark}:{self.path_to_mark}'
                    break
        else:
            set_buf.append(f'{mark}:{self.path_to_mark}')
        set_buf.options['modifiable'] = False
        self.mark_dict[mark] = self.path_to_mark
        self.del_buf('go')
        with open(Vim.Var('NETRBookmarkFile'), 'w') as f:
            for k, p in self.mark_dict.items():
                f.write(f'{k}:{p}\n')
コード例 #4
0
ファイル: ui.py プロジェクト: xbl3/vim-netranger
    def __init__(self, netranger):
        UI.__init__(self)
        self.valid_mark = string.ascii_lowercase + string.ascii_uppercase
        self.netranger = netranger
        self.mark_dict = {}
        self.path_to_mark = None

        # This is to avoid a bug that I can't solve.
        # If bookmark file is initially empty. The first time
        # 'm' (set) mapping is trigger, it won't quit the buffer
        # on user input..
        if not os.path.isfile(Vim.Var('NETRBookmarkFile')):
            with open(Vim.Var('NETRBookmarkFile'), 'w') as f:
                f.write(f'~:{os.path.expanduser("~")}')

        self.load_bookmarks()
コード例 #5
0
ファイル: fs.py プロジェクト: ipod825/vim-netranger
 def __init__(self, target_path=''):
     """ This is a help class for separating local files and remote files
     for mv, cp, rm commands. Though the logic in this class can be done
     in the caller side, it makes the caller has higher branch number and
     hard-to-read code.
     """
     self.remote_targets = []
     self.local_targets = []
     self.remote_root = Vim.Var('NETRemoteCacheDir')
     self.is_remote = self.is_remote_path(target_path)
コード例 #6
0
 def position(self):
     return Vim.Var('NETRSplitOrientation')