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

def lfm::actions::Tree::show (   self  ) 

show tree panel

Definition at line 1766 of file actions.py.

01766                   :
        """show tree panel"""
        
        self.win_tree.erase()
        h = curses.LINES - 4
        n = len(self.tree)
        # box
        self.win_tree.attrset(curses.color_pair(5))
        self.win_tree.box()
        self.win_tree.addstr(0, 2, ' Tree ', curses.color_pair(6) | curses.A_BOLD)
        # tree
        self.win_tree.attrset(curses.color_pair(2))
        j = 0
        a, z = int(self.pos/h) * h, (int(self.pos/h) + 1) * h
        if z > n:
            z = n
            a = z - h
            if a < 0:
                a = 0
        for i in range(a, z):
            j += 1
            name, depth, fullname = self.tree[i]
            if name == os.sep:
                self.win_tree.addstr(j, 1, ' ')
            else:
                self.win_tree.move(j, 1)
                for kk in range(depth):
                    self.win_tree.addstr(' ')
                    self.win_tree.addch(curses.ACS_VLINE)
                    self.win_tree.addstr(' ')
                self.win_tree.addstr(' ')
                if i == n - 1:
                    self.win_tree.addch(curses.ACS_LLCORNER)
                elif depth > self.tree[i+1][1]:
                    self.win_tree.addch(curses.ACS_LLCORNER)
                else:
                    self.win_tree.addch(curses.ACS_LTEE)
                self.win_tree.addch(curses.ACS_HLINE)
                self.win_tree.addstr(' ')
            w = int(curses.COLS / 2) - 2
            wd = 3 * depth + 4
            if fullname == self.path:
                self.win_tree.addstr(name[:w-wd-3], curses.color_pair(3))
                child_dirs = self.__get_dirs(self.path)
                if len(child_dirs) > 0:
                    self.win_tree.addstr(' ')
                    self.win_tree.addch(curses.ACS_HLINE)
                    self.win_tree.addch(curses.ACS_RARROW)
            else:
                self.win_tree.addstr(name[:w-wd])
        # scrollbar
        if n > h:
            nn = int(h * h / n)
            if nn == 0:
                nn = 1
            aa = int(self.pos / h) * h
            y0 = int(aa * h / n)
            if y0 < 0:
                y0 = 0
            elif y0 + nn > h:
                y0 = h - nn - 1
        else:
            y0 = 0
            nn = 0
        self.win_tree.attrset(curses.color_pair(5))
        self.win_tree.vline(y0 + 2, int(curses.COLS/2) - 1, curses.ACS_CKBOARD, nn)
        if a != 0:
            self.win_tree.vline(1, int(curses.COLS/2) - 1, '^', 1)
            if nn == 1 and (y0 + 2 == 2):
                self.win_tree.vline(3, int(curses.COLS/2) - 1, curses.ACS_CKBOARD, nn)
        if n - 1 > a + h - 1:
            self.win_tree.vline(h, int(curses.COLS/2) - 1, 'v', 1)
            if nn == 1 and (y0 + 2 == h + 1):
                self.win_tree.vline(h, int(curses.COLS/2) - 1, curses.ACS_CKBOARD, nn)
        # status
        app.win_status.erase()
        wp = curses.COLS - 8
        if len(self.path) > wp:
            path = self.path[:int(wp/2) -1] + '~' + self.path[-int(wp/2):]
        else:
            path = self.path
        app.win_status.addstr(' Path: %s' % path)
        app.win_status.refresh()


    def run(self):


Generated by  Doxygen 1.6.0   Back to index