def build_status_line(self): s1 = s2 = s3 = '' if self.app.maxw >= 80: size, num = self.get_selected_files_size() if size != -1: s1 = ' %s bytes in %d files' % (self.filesize_to_str(size), num) else: s1 = 'File: %4d of %-4d' %(self.file_i + 1, self.nfiles) filename = self.sorted[self.file_i] #curses.endwin() #print filename res = files.get_fileinfo_dict(self.path, filename,\ self.files[filename],\ #['size', 'mtime', 'perms', 'owner', 'group']) [SIZE, MTIME, PERMS, OWNER, GROUP]) s2 = ''.join([filename,' (', res[SIZE],', ',\ res[MTIME], ', ', res[PERMS], ', ',\ res[OWNER], ', ', res[GROUP], ')']) s2=enc_str(s2) if self.app.maxw > 20: s3 = 'F2;F9=Menu' return s1, s2, s3
def display_cursorbar(self, erase = 0): """draw cursor bar. two modes: erase and select""" if self != self.app.act_pane: return tab = self.act_tab # w = self.frame.dims[1] if (erase): filename = tab.sorted[tab.file_i_prev] attr = tab.get_ftype_clrpair(filename) attr2 = color.PANEL_ACT file_i_pos = tab.file_i_pos + (tab.file_i_prev - tab.file_i) else: filename = tab.sorted[tab.file_i] if tab.selections.count(filename): attr = color.FOCUS_SEL_ITEM else: attr = color.FOCUS_ITEM attr2 = attr file_i_pos = tab.file_i_pos res = files.get_fileinfo_dict(tab.path, filename,\ tab.files[filename], self.frame.show_clms) buf = tab.get_fileinfo_str(res) self.frame.draw_cursor(file_i_pos, buf, attr, attr2)
def display_files(self): """draw file attributes""" tab = self.act_tab w = self.frame.dims[1] self.frame.erase() active = 0 if self == self.app.act_pane: active = 1 if self.mode in [ PANE_MODE_TREE_LEFT, PANE_MODE_TREE_RIGHT]: # treeview data t = self.tree #reinitilize tree with the new path as the lowest level t.path =tab.path t.tree = t.get_tree() t.pos = t.get_curpos() h = self.frame.dims[0] - 3 n = len(t.tree) a, z = int(t.pos/h) * h, (int(t.pos/h) + 1) * h if z > n: z = n a = max(z - h, 0) self.frame.active = True self.frame.refresh_colors() y = 1 for i in range(a, z): y += 1 clr = color.DIR sel = False if t.tree[i][2] == t.path and active: sel = True clr = color.FOCUS_ITEM self.frame.addtree_element(t, i, y, clr, sel) a, n, i =a, n, t.pos else: # listview data for i in range(tab.file_z - tab.file_a + 1): filename = tab.sorted[i + tab.file_a] res = files.get_fileinfo_dict(tab.path, filename,\ tab.files[filename], self.frame.show_clms) attr = tab.get_ftype_clrpair(filename) buf = tab.get_fileinfo_str(res) self.frame.addline(i, buf,attr) a, n, i = tab.file_a, tab.nfiles, tab.file_i self.frame.set_attrib(tab.get_title_path(), \ tab.get_mountpoint_str(),\ self.mode, active, a, n, i) self.frame.refresh()
def display_cursorbar(self): if self == self.app.act_pane: attr_noselected = curses.color_pair(3) attr_selected = curses.color_pair(11) | curses.A_BOLD else: if self.app.prefs.options['manage_otherpane']: attr_noselected = curses.color_pair(20) attr_selected = curses.color_pair(21) else: return if self.mode == PANE_MODE_FULL: cursorbar = curses.newpad(1, self.maxw) else: cursorbar = curses.newpad(1, self.dims[1]-1) cursorbar.bkgd(curses.color_pair(3)) cursorbar.erase() tab = self.act_tab filename = tab.sorted[tab.file_i] try: tab.selections.index(filename) except ValueError: attr = attr_noselected else: attr = attr_selected res = files.get_fileinfo_dict(tab.path, filename, tab.files[filename]) if self.mode == PANE_MODE_FULL: buf = tab.get_fileinfo_str_long(res, self.maxw) cursorbar.addstr(0, 0, utils.encode(buf), attr) cursorbar.refresh(0, 0, tab.file_i % self.dims[0] + 1, 0, tab.file_i % self.dims[0] + 1, self.maxw-2) else: buf = tab.get_fileinfo_str_short(res, self.dims[1], self.pos_col1) cursorbar.addstr(0, 0, utils.encode(buf), attr) cursorbar.addch(0, self.pos_col1-1, curses.ACS_VLINE, attr) cursorbar.addch(0, self.pos_col2-1, curses.ACS_VLINE, attr) row = tab.file_i % (self.dims[0]-3) + 3 if self.mode == PANE_MODE_LEFT: cursorbar.refresh(0, 0, row, 1, row, int(self.maxw/2)-2) else: cursorbar.refresh(0, 0, row, int(self.maxw/2)+1, row, self.maxw-2)
def display_cursorbar(self): if self == self.app.act_pane: attr_noselected = curses.color_pair(3) attr_selected = curses.color_pair(11) | curses.A_BOLD else: if self.app.prefs.options['manage_otherpane']: attr_noselected = curses.color_pair(20) attr_selected = curses.color_pair(21) else: return if self.mode == PANE_MODE_FULL: cursorbar = curses.newpad(1, self.maxw) else: cursorbar = curses.newpad(1, self.dims[1] - 1) cursorbar.bkgd(curses.color_pair(3)) cursorbar.erase() tab = self.act_tab filename = tab.sorted[tab.file_i] try: tab.selections.index(filename) except ValueError: attr = attr_noselected else: attr = attr_selected res = files.get_fileinfo_dict(tab.path, filename, tab.files[filename]) if self.mode == PANE_MODE_FULL: buf = tab.get_fileinfo_str_long(res, self.maxw) cursorbar.addstr(0, 0, utils.encode(buf), attr) cursorbar.refresh(0, 0, tab.file_i % self.dims[0] + 1, 0, tab.file_i % self.dims[0] + 1, self.maxw - 2) else: buf = tab.get_fileinfo_str_short(res, self.dims[1], self.pos_col1) cursorbar.addstr(0, 0, utils.encode(buf), attr) cursorbar.addch(0, self.pos_col1 - 1, curses.ACS_VLINE, attr) cursorbar.addch(0, self.pos_col2 - 1, curses.ACS_VLINE, attr) row = tab.file_i % (self.dims[0] - 3) + 3 if self.mode == PANE_MODE_LEFT: cursorbar.refresh(0, 0, row, 1, row, int(self.maxw / 2) - 2) else: cursorbar.refresh(0, 0, row, int(self.maxw / 2) + 1, row, self.maxw - 2)
def display_files(self): tab = self.act_tab self.win.erase() # calculate pane width, height and vertical start position w = self.dims[1] if self.mode != PANE_MODE_FULL: h, y = self.maxh-5, 2 else: h, y = self.maxh-2, 0 # headers if self.mode != PANE_MODE_FULL: if self == self.app.act_pane: self.win.attrset(curses.color_pair(5)) attr = curses.color_pair(6) | curses.A_BOLD else: self.win.attrset(curses.color_pair(2)) attr = curses.color_pair(2) path = tab.vfs and vfs.join(tab) or tab.path path = (len(path)>w-5) and '~' + path[-w+5:] or path self.win.box() self.win.addstr(0, 2, utils.encode(path), attr) self.win.addstr(1, 1, 'Name'.center(self.pos_col1-2)[:self.pos_col1-2], curses.color_pair(2) | curses.A_BOLD) self.win.addstr(1, self.pos_col1+2, 'Size', curses.color_pair(2) | curses.A_BOLD) self.win.addstr(1, self.pos_col2+5, 'Date', curses.color_pair(2) | curses.A_BOLD) else: if tab.nfiles > h: self.win.vline(0, w-1, curses.ACS_VLINE, h) # files for i in xrange(tab.file_z - tab.file_a + 1): filename = tab.sorted[i+tab.file_a] # get file info res = files.get_fileinfo_dict(tab.path, filename, tab.files[filename]) # get file color if tab.selections.count(filename): attr = curses.color_pair(10) | curses.A_BOLD else: if self.app.prefs.options['color_files']: attr = self.get_filetypecolorpair(filename, tab.files[filename][files.FT_TYPE]) else: attr = curses.color_pair(2) # show if self.mode == PANE_MODE_FULL: buf = tab.get_fileinfo_str_long(res, w) self.win.addstr(i, 0, utils.encode(buf), attr) else: buf = tab.get_fileinfo_str_short(res, w, self.pos_col1) self.win.addstr(i+2, 1, utils.encode(buf), attr) # vertical separators if self.mode != PANE_MODE_FULL: self.win.vline(1, self.pos_col1, curses.ACS_VLINE, self.dims[0]-2) self.win.vline(1, self.pos_col2, curses.ACS_VLINE, self.dims[0]-2) # vertical scroll bar y0, n = self.__calculate_scrollbar_dims(h, tab.nfiles, tab.file_i) self.win.vline(y+y0, w-1, curses.ACS_CKBOARD, n) if tab.file_a != 0: self.win.vline(y, w-1, '^', 1) if (n == 1) and (y0 == 0): self.win.vline(y+1, w-1, curses.ACS_CKBOARD, n) if tab.nfiles > tab.file_a + h: self.win.vline(h+y-1, w-1, 'v', 1) if (n == 1) and (y0 == h-1): self.win.vline(h+y-2, w-1, curses.ACS_CKBOARD, n) self.win.refresh()
def display_files(self): tab = self.act_tab self.win.erase() # calculate pane width, height and vertical start position w = self.dims[1] if self.mode != PANE_MODE_FULL: h, y = self.maxh - 5, 2 else: h, y = self.maxh - 2, 0 # headers if self.mode != PANE_MODE_FULL: if self == self.app.act_pane: self.win.attrset(curses.color_pair(5)) attr = curses.color_pair(6) | curses.A_BOLD else: self.win.attrset(curses.color_pair(2)) attr = curses.color_pair(2) path = tab.vfs and vfs.join(tab) or tab.path path = (len(path) > w - 5) and '~' + path[-w + 5:] or path self.win.box() self.win.addstr(0, 2, utils.encode(path), attr) self.win.addstr( 1, 1, 'Name'.center(self.pos_col1 - 2)[:self.pos_col1 - 2], curses.color_pair(2) | curses.A_BOLD) self.win.addstr(1, self.pos_col1 + 2, 'Size', curses.color_pair(2) | curses.A_BOLD) self.win.addstr(1, self.pos_col2 + 5, 'Date', curses.color_pair(2) | curses.A_BOLD) else: if tab.nfiles > h: self.win.vline(0, w - 1, curses.ACS_VLINE, h) # files for i in xrange(tab.file_z - tab.file_a + 1): filename = tab.sorted[i + tab.file_a] # get file info res = files.get_fileinfo_dict(tab.path, filename, tab.files[filename]) # get file color if tab.selections.count(filename): attr = curses.color_pair(10) | curses.A_BOLD else: if self.app.prefs.options['color_files']: attr = self.get_filetypecolorpair( filename, tab.files[filename][files.FT_TYPE]) else: attr = curses.color_pair(2) # show if self.mode == PANE_MODE_FULL: buf = tab.get_fileinfo_str_long(res, w) self.win.addstr(i, 0, utils.encode(buf), attr) else: buf = tab.get_fileinfo_str_short(res, w, self.pos_col1) self.win.addstr(i + 2, 1, utils.encode(buf), attr) # vertical separators if self.mode != PANE_MODE_FULL: self.win.vline(1, self.pos_col1, curses.ACS_VLINE, self.dims[0] - 2) self.win.vline(1, self.pos_col2, curses.ACS_VLINE, self.dims[0] - 2) # vertical scroll bar y0, n = self.__calculate_scrollbar_dims(h, tab.nfiles, tab.file_i) self.win.vline(y + y0, w - 1, curses.ACS_CKBOARD, n) if tab.file_a != 0: self.win.vline(y, w - 1, '^', 1) if (n == 1) and (y0 == 0): self.win.vline(y + 1, w - 1, curses.ACS_CKBOARD, n) if tab.nfiles > tab.file_a + h: self.win.vline(h + y - 1, w - 1, 'v', 1) if (n == 1) and (y0 == h - 1): self.win.vline(h + y - 2, w - 1, curses.ACS_CKBOARD, n) self.win.refresh()