diff options
author | hut <hut@lavabit.com> | 2009-11-25 17:55:34 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-11-25 17:55:34 +0100 |
commit | 5822dff7d91472bf2fc337c68f144e0ce1de09ae (patch) | |
tree | 7d40218b67f13c9c95141aa5bcb4aa292c42924a /code/ui.py | |
parent | cfbb8c84355f28bc7f669105f90c7aae0a972569 (diff) | |
download | ranger-5822dff7d91472bf2fc337c68f144e0ce1de09ae.tar.gz |
implemented more stuff
Diffstat (limited to 'code/ui.py')
-rw-r--r-- | code/ui.py | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/code/ui.py b/code/ui.py index 3994d7ce..d9c1de4e 100644 --- a/code/ui.py +++ b/code/ui.py @@ -1,26 +1,28 @@ import curses, debug class UI(): - def __init__(self, options): - self.scr = curses.initscr() - self.scr.leaveok(1) + def __init__(self, env): + self.env = env + + self.widgets = [] + self.win = curses.initscr() + self.win.leaveok(1) curses.noecho() curses.halfdelay(3) - self.options = options - self.directories = None - self.pwd = None - self.cf = None - self.termsize = None - self.rows = 0 - self.cols = 0 - - def feed(self, directories, pwd, cf, termsize): - self.directories = directories - self.pwd = pwd - self.cf = cf - self.termsize = termsize - self.cols = termsize.x - self.rows = termsize.y + self.setup() + self.resize() + + def setup(self): + pass + + def resize(self): + self.env.termsize = self.win.getmaxyx() + + def add_widget(self, widg): + self.widgets.append(widg) + + def feed_env(self, env): + self.env = env def exit(self): curses.nocbreak() @@ -28,16 +30,19 @@ class UI(): curses.endwin() def draw(self): - import time - self.scr.erase() - for i in range(1, len(self.pwd)): - 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() + self.win.erase() + for widg in self.widgets: + widg.feed_env(self.env) + widg.draw() + self.win.refresh() + +# for i in range(1, len(self.env.pwd)): +# f = self.env.pwd.files[i] +# self.win.addstr(i, 0, f.path) +# if f.infostring: self.win.addstr(i, 50, f.infostring) def get_next_key(self): - key = self.scr.getch() + key = self.win.getch() curses.flushinp() return key |