summary refs log tree commit diff stats
path: root/code/ui.py
diff options
context:
space:
mode:
Diffstat (limited to 'code/ui.py')
-rw-r--r--code/ui.py57
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
 
0 committer Ben Morrison <ben@gbmor.dev> 2019-05-28 01:17:30 -0400 configuration via flags is more flexible.' href='/gbmor/getwtxt/commit/init.go?h=v0.3.1&id=cf6c8491063db9f96aac139beb3dbb296ae795c3'>cf6c849 ^
8630499 ^
cf6c849 ^
69217dd ^


a0be15e ^

cd635e6 ^
06cffd8 ^

d083ce6 ^
06cffd8 ^
bd23ef0 ^

887c25e ^
bd23ef0 ^
e34697c ^
920306c ^
efa99ed ^

c896e6b ^
df1d1ef ^
4695425 ^
2b0d4a5 ^
6c1b09b ^











6753171 ^



f2d85b6 ^
1f8b2ce ^
06cffd8 ^
06cffd8 ^
c896e6b ^
71971db ^
e34697c ^
5310d08 ^
06cffd8 ^

f2d85b6 ^
1f8b2ce ^
f2d85b6 ^




bd23ef0 ^

f2d85b6 ^
67864b2 ^
cf6c849 ^





f2d85b6 ^

5310d08 ^







5310d08 ^
c896e6b ^
cd635e6 ^
cd635e6 ^
887c25e ^
b29e1c1 ^
887c25e ^

887c25e ^
78f4d8a ^


c896e6b ^

cd635e6 ^
d083ce6 ^
5310d08 ^

cd635e6 ^
b29e1c1 ^
d083ce6 ^
efa99ed ^

c896e6b ^
5310d08 ^



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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123