blob: 1beb0b6520cfa9dcd66e71f7d16b9a1319a6b1a3 (
plain)
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
|
# Module 'filewin'
# File windows, a subclass of textwin (which is a subclass of gwin)
import stdwin
import textwin
import path
builtin_open = open
def readfile(fn): # Return a string containing the file's contents
fp = builtin_open(fn, 'r')
a = ''
n = 8096
while 1:
b = fp.read(n)
if not b: break
a = a + b
return a
# FILE WINDOW
def open_readonly(fn): # Open a file window
w = textwin.open_readonly(fn, readfile(fn))
w.fn = fn
return w
def open(fn): # Open a file window
w = textwin.open(fn, readfile(fn))
w.fn = fn
return w
|