Exemplo n.º 1
0
    def draw_titlebar(self):
        self.titlebar.erase()
        self.titlebar.move(0, 0)
        length = sum([util.termwidth(w.title)+2 for w in self.workspaces])
        y, x = self.stdscr.getmaxyx()

        for i, ws in enumerate(self.workspaces):
            if self.cursor == i:
                self.titlebar.addstr(" {0} ".format(ws.title), look.colors["WorkspaceFocus"])
            else:
                self.titlebar.addstr(" {0} ".format(ws.title))
        self.titlebar.addstr(" | ", curses.A_BOLD)

        dirlen = len(self.workspace.dirs)
        width = (x-length-4) // dirlen
        odd = (x-length-4) % dirlen

        for i, path in enumerate([d.path for d in self.workspace.dirs]):
            num = "[{0}] ".format(i+1)
            numlen = len(num)
            path = util.replhome(path)
            if path.endswith(os.sep):
                path = util.path_omission(path, width-numlen-1)
            else:
                path = util.path_omission(path, width-numlen-1-len(os.sep)) + os.sep
            if i == 0:
                w = width-numlen+odd
            else:
                w = width-numlen
            string = num + util.mbs_rjust(path, w)
            if i == self.workspace.cursor:
                self.titlebar.addstr(string, look.colors["TitlebarFocus"])
            else:
                self.titlebar.addstr(string)
        self.titlebar.noutrefresh()
Exemplo n.º 2
0
 def _draw_titlebar(self, width):
     title = ""
     titlewidth = width
     if not self.path.endswith(os.sep):
         title += os.sep
         titlewidth -= len(os.sep)
     if self.maskreg:
         title += "{{{0}}}".format(self.maskreg.pattern)
         titlewidth -= util.termwidth(self.maskreg.pattern)
     path = util.replhome(self.path)
     path = util.path_omission(path, titlewidth)
     self.screen.win.addstr(0, 2, path+title, look.colors["DirectoryPath"])