Logo Search packages:      
Sourcecode: ranger version File versions  Download package

def ranger::gui::widgets::browsercolumn::BrowserColumn::_draw_directory (   self ) [private]
Draw the contents of a directory

Definition at line 175 of file browsercolumn.py.

                               :
            """Draw the contents of a directory"""

            if self.level > 0 and not self.settings.preview_directories:
                  return

            base_color = ['in_browser']

            self.win.move(0, 0)

            if not self.target.content_loaded:
                  self.color(base_color)
                  self.addnstr("...", self.wid)
                  self.color_reset()
                  return

            if self.main_column:
                  base_color.append('main_column')

            if not self.target.accessible:
                  self.color(base_color, 'error')
                  self.addnstr("not accessible", self.wid)
                  self.color_reset()
                  return

            if self.target.empty():
                  self.color(base_color, 'empty')
                  self.addnstr("empty", self.wid)
                  self.color_reset()
                  return

            self._set_scroll_begin()

            copied = [f.path for f in self.env.copy]
            ellipsis = self.ellipsis[self.settings.unicode_ellipsis]

            selected_i = self.target.pointer
            for line in range(self.hei):
                  i = line + self.scroll_begin

                  try:
                        drawn = self.target.files[i]
                  except IndexError:
                        break

                  if self.display_infostring and drawn.infostring \
                              and self.settings.display_size_in_main_column:
                        infostring = str(drawn.infostring) + " "
                  else:
                        infostring = ""

                  bad_info_color = None
                  this_color = base_color + list(drawn.mimetype_tuple)
                  text = drawn.basename
                  tagged = self.fm.tags and drawn.realpath in self.fm.tags

                  space = self.wid - len(infostring)
                  if self.main_column:
                        space -= 2

#                 if len(text) > space:
#                       text = text[:space-1] + self.ellipsis

                  if i == selected_i:
                        this_color.append('selected')

                  if drawn.marked:
                        this_color.append('marked')
                        if self.main_column:
                              text = " " + text

                  if tagged:
                        this_color.append('tagged')
                        if self.main_column:
                              text = self.tagged_marker + text

                  if drawn.is_directory:
                        this_color.append('directory')
                  else:
                        this_color.append('file')

                  if drawn.stat:
                        mode = drawn.stat.st_mode
                        if mode & stat.S_IXUSR:
                              this_color.append('executable')
                        if stat.S_ISFIFO(mode):
                              this_color.append('fifo')
                        if stat.S_ISSOCK(mode):
                              this_color.append('socket')
                        if drawn.is_device:
                              this_color.append('device')

                  if drawn.path in copied:
                        this_color.append('cut' if self.env.cut else 'copied')

                  if drawn.is_link:
                        this_color.append('link')
                        this_color.append(drawn.exists and 'good' or 'bad')

                  string = drawn.basename
                  from ranger.ext.widestring import WideString
                  wtext = WideString(text)
                  if len(wtext) > space:
                        wtext = wtext[:space - 1] + ellipsis
                  if self.main_column:
                        if tagged:
                              self.addstr(line, 0, str(wtext))
                        elif self.wid > 1:
                              self.addstr(line, 1, str(wtext))
                  else:
                        self.addstr(line, 0, str(wtext))

                  if infostring:
                        x = self.wid - 1 - len(infostring)
                        if infostring is BAD_INFO:
                              bad_info_color = (x, len(infostring))
                        if x > 0:
                              self.addstr(line, x, infostring)

                  self.color_at(line, 0, self.wid, this_color)
                  if bad_info_color:
                        start, wid = bad_info_color
                        self.color_at(line, start, wid, this_color, 'badinfo')

                  if self.main_column and tagged and self.wid > 2:
                        this_color.append('tag_marker')
                        self.color_at(line, 0, len(self.tagged_marker), this_color)

                  self.color_reset()


Generated by  Doxygen 1.6.0   Back to index