blob: c2fe30a4f63286f7cb6bc4d3fb0f49092685d6b7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import sys
import ui, debug, directory
class FM():
def __init__(self, options, environment):
self.options = options
self.env = environment
def setup(self, path, ui):
self.ui = ui
self.enter_dir(path)
def enter_dir(self, path):
self.env.path = path
try:
self.pwd = self.env.directories[path]
except KeyError:
self.env.pwd = directory.Directory(path)
self.env.directories[path] = self.env.pwd
self.env.pwd.load_content()
if len(self.env.pwd) > 0: self.env.cf = self.env.pwd[0]
def run(self):
try:
while 1:
try:
self.ui.feed(self.env.directories, self.env.pwd, self.env.cf, self.env.termsize)
self.ui.draw()
except KeyboardInterrupt:
self.interrupt()
except:
raise
try:
key = self.ui.get_next_key()
self.press(key)
except KeyboardInterrupt:
self.interrupt()
except:
self.ui.exit()
raise
def press(self, key):
if (key == ord('q')):
raise SystemExit()
def interrupt(self):
import time
self.buffer = ""
time.sleep(0.2)
|