Пример #1
0
 def set_title(self, path):
     '''Update name of tab and return tuple of two elements
         text    list of two unicode obj (will be inserted before filenames in view) or empty list
         header  boolean, value of dired_header setting
         '''
     header  = self.view.settings().get('dired_header', False)
     name    = jump_names().get(path or self.path)
     caption = u"{0} → {1}".format(name, path) if name else path or self.path
     text    = [caption, len(caption)*(u'—')] if header else []
     icon    = self.view.name()[:2]
     if not path:
         title = u'%s%s' % (icon, name or 'This PC')
     else:
         norm_path = path.rstrip(os.sep)
         if self.view.settings().get('dired_show_full_path', False):
             title = u'%s%s (%s)' % (icon, name or basename(norm_path), norm_path)
         else:
             title = u'%s%s' % (icon, name or basename(norm_path))
     self.view.set_name(title)
     return (text, header)
Пример #2
0
 def set_title(self, path):
     '''Update name of tab and return tuple of two elements
         text    list of two unicode obj (will be inserted before filenames in view) or empty list
         header  boolean, value of dired_header setting
         '''
     header  = self.view.settings().get('dired_header', False)
     name    = jump_names().get(path or self.path)
     caption = u"{0} → {1}".format(name, path) if name else path or self.path
     text    = [caption, len(caption)*(u'—')] if header else []
     icon    = self.view.name()[:2]
     if not path:
         title = u'%s%s' % (icon, name or 'This PC')
     else:
         norm_path = path.rstrip(os.sep)
         if self.view.settings().get('dired_show_full_path', False):
             title = u'%s%s (%s)' % (icon, name or basename(norm_path), norm_path)
         else:
             title = u'%s%s' % (icon, name or basename(norm_path))
     self.view.set_name(title)
     return (text, header)
Пример #3
0
    def continue_refreshing(self, edit, path, names, goto=None):
        status = status = u" ­Юїє [?: Help] "
        path_in_project = any(folder == self.path[:-1] for folder in self.view.window().folders())
        status += 'Project root, ' if path_in_project else ''
        show_hidden = self.view.settings().get('dired_show_hidden_files', True)
        status += 'Hidden: On' if show_hidden else 'Hidden: Off'
        self.view.set_status("__FileBrowser__", status)

        if not show_hidden:
            if sublime.platform() == 'windows':
                names = [name for name in names if not (name.startswith('.') or  has_hidden_attribute(join(path, name)))]
            else:
                names = [name for name in names if not name.startswith('.')]
        sort_nicely(names)

        f = []

        # generating dirs list first
        for name in names:
            if isdir(join(path, name)):
                name = u"РќИ " + name + os.sep
                f.append(name)

        # generating files list
        for name in names:
            if not isdir(join(path, name)):
                name = u"РЅА " + name
                f.append(name)

        marked = set(self.get_marked())

        name = jump_names().get(path)
        caption = u"{0} Рєњ {1}".format(name, path) if name else path
        text = [ caption ]
        text.append(len(caption)*(u'Рђћ'))
        if not f or self.show_parent():
            text.append(PARENT_SYM)
        text.extend(f)

        self.view.set_read_only(False)

        self.view.erase(edit, Region(0, self.view.size()))
        self.view.insert(edit, 0, '\n'.join(text))
        self.view.set_syntax_file('Packages/FileBrowser/dired.hidden-tmLanguage')
        self.view.settings().set('dired_count', len(f))

        if marked:
            # Even if we have the same filenames, they may have moved so we have to manually
            # find them again.
            regions = []
            for line in self.view.lines(self.fileregion()):
                filename = self._remove_ui(RE_FILE.match(self.view.substr(line)).group(1))
                if filename in marked:
                    name_region = Region(line.a + 2, line.b) # do not mark UI elements
                    regions.append(name_region)
            self.view.add_regions('marked', regions, 'dired.marked', '', MARK_OPTIONS)
        else:
            self.view.erase_regions('marked')

        self.view.set_read_only(True)

        # Place the cursor.
        if f:
            pt = self.fileregion(with_parent_link=True).a
            if goto:
                if isdir(join(path, goto)) and not goto.endswith(os.sep):
                    goto = u"РќИ " + goto + os.sep
                else:
                    goto = u"РЅА " + goto
                try:
                    line = f.index(goto) + (3 if self.show_parent() else 2)
                    pt = self.view.text_point(line, 2)
                except ValueError:
                    pass

            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
            self.view.show_at_center(Region(pt, pt))
        else: # empty folder?
            pt = self.view.text_point(2, 0)
            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
Пример #4
0
    def continue_refreshing(self, edit, path, names, goto=None):
        f = []

        # generating dirs list first
        for name in names:
            if isdir(join(path, name)):
                try:
                    name = "РќИ ".decode(ECODING) + name + os.sep
                except:
                    name = "РќИ " + name + os.sep
                f.append(name)

        # generating files list
        for name in names:
            if not isdir(join(path, name)):
                try:
                    name = "РЅА ".decode(ECODING) + name
                except:
                    name = "РЅА " + name
                f.append(name)

        marked = set(self.get_marked())

        name = jump_names().get(path)
        caption = "{0} -> {1}".format(name, path) if name else path
        text = [ caption ]
        try:
            text.append(len(caption)*('Рђћ'.decode(ECODING)))
        except:
            text.append(len(caption)*('Рђћ'))
        if not f or self.show_parent():
            text.append(PARENT_SYM)
        text.extend(f)

        self.view.set_read_only(False)

        self.view.erase(edit, Region(0, self.view.size()))
        self.view.insert(edit, 0, '\n'.join(text))
        self.view.set_syntax_file('Packages/FileBrowser/dired.hidden-tmLanguage')
        self.view.settings().set('dired_count', len(f))

        if marked:
            # Even if we have the same filenames, they may have moved so we have to manually
            # find them again.
            regions = []
            for line in self.view.lines(self.fileregion()):
                filename = self._remove_ui(RE_FILE.match(self.view.substr(line)).group(1))
                if filename in marked:
                    name_region = Region(line.a + 2, line.b) # do not mark UI elements
                    regions.append(name_region)
            self.view.add_regions('marked', regions, 'dired.marked', '', MARK_OPTIONS)
        else:
            self.view.erase_regions('marked')

        self.view.set_read_only(True)

        # Place the cursor.
        if f:
            pt = self.fileregion(with_parent_link=True).a
            if goto:
                if isdir(join(path, goto)) and not goto.endswith(os.sep):
                    try:
                        goto = "РќИ ".decode(ECODING) + goto + os.sep
                    except:
                        goto = "РќИ " + goto + os.sep
                else:
                    try:
                        goto = "РЅА ".decode(ECODING) + goto
                    except:
                        goto = "РЅА " + goto
                try:
                    line = f.index(goto) + (3 if self.show_parent() else 2)
                    pt = self.view.text_point(line, 2)
                except ValueError:
                    pass

            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
            self.view.show_at_center(Region(pt, pt))
        else: # empty folder?
            pt = self.view.text_point(2, 0)
            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
Пример #5
0
    def continue_refreshing(self, edit, path, names, goto=None):
        status = status = u" ­Юїє [?: Help] "
        path_in_project = any(folder == self.path[:-1]
                              for folder in self.view.window().folders())
        status += 'Project root, ' if path_in_project else ''
        show_hidden = self.view.settings().get('dired_show_hidden_files', True)
        status += 'Hidden: On' if show_hidden else 'Hidden: Off'
        self.view.set_status("__FileBrowser__", status)

        if not show_hidden:
            names = [name for name in names if not self.is_hidden(name)]
        sort_nicely(names)

        f = []

        # generating dirs list first
        for name in names:
            if isdir(join(path, name)):
                name = u"РќИ " + name + os.sep
                f.append(name)

        # generating files list
        for name in names:
            if not isdir(join(path, name)):
                name = u"РЅА " + name
                f.append(name)

        marked = set(self.get_marked())

        name = jump_names().get(path)
        caption = u"{0} Рєњ {1}".format(name, path) if name else path
        text = [caption]
        text.append(len(caption) * (u'Рђћ'))
        if not f or self.show_parent():
            text.append(PARENT_SYM)
        text.extend(f)

        self.view.set_read_only(False)

        self.view.erase(edit, Region(0, self.view.size()))
        self.view.insert(edit, 0, '\n'.join(text))
        self.view.set_syntax_file(
            'Packages/FileBrowser/dired.hidden-tmLanguage')
        self.view.settings().set('dired_count', len(f))

        if marked:
            # Even if we have the same filenames, they may have moved so we have to manually
            # find them again.
            regions = []
            for line in self.view.lines(self.fileregion()):
                filename = self._remove_ui(
                    RE_FILE.match(self.view.substr(line)).group(1))
                if filename in marked:
                    name_region = Region(line.a + 2,
                                         line.b)  # do not mark UI elements
                    regions.append(name_region)
            self.view.add_regions('marked', regions, 'dired.marked', '',
                                  MARK_OPTIONS)
        else:
            self.view.erase_regions('marked')

        self.view.set_read_only(True)

        # Place the cursor.
        if f:
            pt = self.fileregion(with_parent_link=True).a
            if goto:
                if isdir(join(path, goto)) and not goto.endswith(os.sep):
                    goto = u"РќИ " + goto + os.sep
                else:
                    goto = u"РЅА " + goto
                try:
                    line = f.index(goto) + (3 if self.show_parent() else 2)
                    pt = self.view.text_point(line, 2)
                except ValueError:
                    pass

            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
            self.view.show_at_center(Region(pt, pt))
        else:  # empty folder?
            pt = self.view.text_point(2, 0)
            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
Пример #6
0
    def continue_refreshing(self, edit, path, names, goto=None, indent=''):
        status = u" ­Юїє [?: Help] "
        path_in_project = any(folder == self.path[:-1] for folder in self.view.window().folders())
        status += 'Project root, ' if path_in_project else ''
        show_hidden = self.view.settings().get('dired_show_hidden_files', True)
        status += 'Hidden: On' if show_hidden else 'Hidden: Off'
        self.view.set_status("__FileBrowser__", status)

        if not show_hidden:
            names = [name for name in names if not self.is_hidden(name)]
        sort_nicely(names)

        f = self.ls(path, names, goto=goto if indent else '', indent=indent)

        marked = set(self.get_marked())

        self.view.set_read_only(False)

        if indent:
            line = self.view.line(self.view.sel()[0])
            name_point = self.view.extract_scope(line.b - 1).a
        if indent and f:
            icon_region = Region(name_point - 2, name_point - 1)
            self.view.replace(edit, icon_region, u'РќЙ')
            self.view.insert(edit, line.b, '\n'+'\n'.join(f))
            dired_count = self.view.settings().get('dired_count', 0)
            self.view.settings().set('dired_count', int(dired_count) + len(f))
        elif indent:
            self.view.insert(edit, self.view.line(self.view.sel()[0]).b, '\t<empty>')
        else:
            name = jump_names().get(path)
            caption = u"{0} Рєњ {1}".format(name, path) if name else path
            text = [ caption ]
            text.append(len(caption)*(u'Рђћ'))
            if not f or self.show_parent():
                text.append(PARENT_SYM)
            text.extend(f)

            self.view.erase(edit, Region(0, self.view.size()))
            self.view.insert(edit, 0, '\n'.join(text))
            self.view.settings().set('dired_count', len(f))

        if marked:
            # Even if we have the same filenames, they may have moved so we have to manually
            # find them again.
            regions = []
            for line in self.view.lines(self.fileregion()):
                filename = self._remove_ui(RE_FILE.match(self.view.substr(line)).group(1))
                if filename in marked:
                    name_region = Region(line.a + 2, line.b) # do not mark UI elements
                    regions.append(name_region)
            self.view.add_regions('marked', regions, 'dired.marked', '', MARK_OPTIONS)
        else:
            self.view.erase_regions('marked')

        self.view.set_read_only(True)

        # Place the cursor.
        if f and not indent:
            pt = self.fileregion(with_parent_link=True).a
            if goto:
                if isdir(join(path, goto)) and not goto.endswith(os.sep):
                    goto = u"РќИ " + goto + os.sep
                else:
                    goto = u"РЅА " + goto
                try:
                    line = f.index(goto) + (3 if self.show_parent() else 2)
                    pt = self.view.text_point(line, 2)
                except ValueError:
                    pass

            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
            self.view.show_at_center(Region(pt, pt))
        elif not f and not indent: # empty folder?
            pt = self.view.text_point(2, 0)
            self.view.sel().clear()
            self.view.sel().add(Region(pt, pt))
        else:
            self.view.sel().clear()
            self.view.sel().add(Region(name_point, name_point))
            self.view.show_at_center(name_point)