blob: 1beb0b6520cfa9dcd66e71f7d16b9a1319a6b1a3 [file] [log] [blame]
Guido van Rossumc6360141990-10-13 19:23:40 +00001# Module 'filewin'
2# File windows, a subclass of textwin (which is a subclass of gwin)
3
4import stdwin
5import textwin
6import path
7
8builtin_open = open
9
10def readfile(fn): # Return a string containing the file's contents
11 fp = builtin_open(fn, 'r')
12 a = ''
13 n = 8096
14 while 1:
15 b = fp.read(n)
16 if not b: break
17 a = a + b
18 return a
19
20
21# FILE WINDOW
22
23def open_readonly(fn): # Open a file window
24 w = textwin.open_readonly(fn, readfile(fn))
25 w.fn = fn
26 return w
27
28def open(fn): # Open a file window
29 w = textwin.open(fn, readfile(fn))
30 w.fn = fn
31 return w