8 from EditorWindow
import EditorWindow
# class variable, may be overridden
9 # e.g. by PyShellFileList
11 def __init__(self
, root
):
15 self
.vars = {} # For EditorWindow.getrawvar (shared Tcl variables)
17 def open(self
, filename
, action
=None):
19 filename
= self
.canonize(filename
)
20 if os
.path
.isdir(filename
):
21 # This can happen when bad filename is passed on command line:
22 tkMessageBox
.showerror(
24 "%r is a directory." % (filename
,),
27 key
= os
.path
.normcase(filename
)
28 if self
.dict.has_key(key
):
33 # Don't create window, perform 'action', e.g. open in same window
34 return action(filename
)
36 return self
.EditorWindow(self
, filename
, key
)
38 def gotofileline(self
, filename
, lineno
=None):
39 edit
= self
.open(filename
)
40 if edit
is not None and lineno
is not None:
43 def new(self
, filename
=None):
44 return self
.EditorWindow(self
, filename
)
46 def close_all_callback(self
, event
):
47 for edit
in self
.inversedict
.keys():
53 def close_edit(self
, edit
):
55 key
= self
.inversedict
[edit
]
57 print "Don't know this EditorWindow object. (close)"
61 del self
.inversedict
[edit
]
62 if not self
.inversedict
:
65 def filename_changed_edit(self
, edit
):
66 edit
.saved_change_hook()
68 key
= self
.inversedict
[edit
]
70 print "Don't know this EditorWindow object. (rename)"
72 filename
= edit
.io
.filename
76 self
.inversedict
[edit
] = None
78 filename
= self
.canonize(filename
)
79 newkey
= os
.path
.normcase(filename
)
82 if self
.dict.has_key(newkey
):
83 conflict
= self
.dict[newkey
]
84 self
.inversedict
[conflict
] = None
85 tkMessageBox
.showerror(
87 "You now have multiple edit windows open for %r" % (filename
,),
89 self
.dict[newkey
] = edit
90 self
.inversedict
[edit
] = newkey
97 def canonize(self
, filename
):
98 if not os
.path
.isabs(filename
):
104 filename
= os
.path
.join(pwd
, filename
)
105 return os
.path
.normpath(filename
)
109 from EditorWindow
import fixwordbreaks
114 flist
= FileList(root
)
116 for filename
in sys
.argv
[1:]:
120 if flist
.inversedict
:
123 if __name__
== '__main__':