diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/directory.py | 15 | ||||
-rw-r--r-- | code/fm.py | 4 | ||||
-rw-r--r-- | code/fsobject.py | 9 | ||||
-rw-r--r-- | code/ui.py | 6 |
4 files changed, 27 insertions, 7 deletions
diff --git a/code/directory.py b/code/directory.py index ef68d35f..da7c0948 100644 --- a/code/directory.py +++ b/code/directory.py @@ -1,5 +1,5 @@ import fsobject -import file +import file, debug class Directory(fsobject.FSObject): def __init__(self, path): @@ -19,10 +19,17 @@ class Directory(fsobject.FSObject): self.content_loaded = True import os if self.exists: - self.filenames = os.listdir(self.path) + basenames = os.listdir(self.path) + mapped = map(lambda name: os.path.join(self.path, name), basenames) + self.filenames = list(mapped) + self.infostring = ' %d' % len(self.filenames) + debug.log('infostring set!') self.files = [] for name in self.filenames: - f = file.File(name) + if os.path.isdir(name): + f = Directory(name) + else: + f = file.File(name) f.load() self.files.append(f) @@ -36,7 +43,7 @@ class Directory(fsobject.FSObject): def __getitem__(self, key): if not self.accessible: raise fsobject.NotLoadedYet() - return self.filenames[key] + return self.files[key] if __name__ == '__main__': d = Directory('.') diff --git a/code/fm.py b/code/fm.py index c2fe30a4..6631aee4 100644 --- a/code/fm.py +++ b/code/fm.py @@ -1,5 +1,5 @@ import sys -import ui, debug, directory +import ui, debug, directory, fstype class FM(): def __init__(self, options, environment): @@ -25,6 +25,8 @@ class FM(): try: while 1: try: +# if type(self.env.cf) is directory.Directory: +# self.env.cf.load_content_once() self.ui.feed(self.env.directories, self.env.pwd, self.env.cf, self.env.termsize) self.ui.draw() except KeyboardInterrupt: diff --git a/code/fsobject.py b/code/fsobject.py index 1e194ac9..148976d2 100644 --- a/code/fsobject.py +++ b/code/fsobject.py @@ -17,6 +17,8 @@ class FSObject(object): self.islink = False self.brokenlink = False self.stat = None + self.infostring = None + self.permissions = None self.type = fstype.Unknown # load() reads useful information about the file from the file system @@ -34,10 +36,17 @@ class FSObject(object): if os.path.isdir(self.path): self.type = fstype.Directory + self.infostring = '--' elif os.path.isfile(self.path): self.type = fstype.File + self.infostring = ' %d' % self.stat.st_size + else: + self.type = fstype.Unknown + self.infostring = None + except OSError: self.islink = False + self.infostring = None self.type = fstype.Nonexistent self.exists = False self.accessible = False diff --git a/code/ui.py b/code/ui.py index 7d8fd828..3994d7ce 100644 --- a/code/ui.py +++ b/code/ui.py @@ -1,4 +1,4 @@ -import curses +import curses, debug class UI(): def __init__(self, options): self.scr = curses.initscr() @@ -31,7 +31,9 @@ class UI(): import time self.scr.erase() for i in range(1, len(self.pwd)): - self.scr.addstr(i, 0, self.pwd[i]) + f = self.pwd.files[i] + self.scr.addstr(i, 0, f.path) + if f.infostring: self.scr.addstr(i, 50, f.infostring) self.scr.refresh() def get_next_key(self): |