Commit d2f4861a authored by Kurt B. Kaiser's avatar Kurt B. Kaiser

SF 748973 Guido van Rossum patch

New Window should save in the directory of the Editor Window
from which it was selected.

M EditorWindow.py
M FileList.py
M IOBinding.py
parent a1045567
...@@ -139,7 +139,7 @@ class EditorWindow: ...@@ -139,7 +139,7 @@ class EditorWindow:
flist.inversedict[self] = key flist.inversedict[self] = key
if key: if key:
flist.dict[key] = self flist.dict[key] = self
text.bind("<<open-new-window>>", self.flist.new_callback) text.bind("<<open-new-window>>", self.new_callback)
text.bind("<<close-all-windows>>", self.flist.close_all_callback) text.bind("<<close-all-windows>>", self.flist.close_all_callback)
text.bind("<<open-class-browser>>", self.open_class_browser) text.bind("<<open-class-browser>>", self.open_class_browser)
text.bind("<<open-path-browser>>", self.open_path_browser) text.bind("<<open-path-browser>>", self.open_path_browser)
...@@ -182,7 +182,7 @@ class EditorWindow: ...@@ -182,7 +182,7 @@ class EditorWindow:
self.UpdateRecentFilesList() self.UpdateRecentFilesList()
if filename: if filename:
if os.path.exists(filename): if os.path.exists(filename) and not os.path.isdir(filename):
io.loadfile(filename) io.loadfile(filename)
else: else:
io.set_filename(filename) io.set_filename(filename)
...@@ -210,6 +210,11 @@ class EditorWindow: ...@@ -210,6 +210,11 @@ class EditorWindow:
self.extensions['AutoIndent'].set_indentation_params( self.extensions['AutoIndent'].set_indentation_params(
self.ispythonsource(filename)) self.ispythonsource(filename))
def new_callback(self, event):
dirname, basename = self.io.defaultfilename()
self.flist.new(dirname)
return "break"
def set_status_bar(self): def set_status_bar(self):
self.status_bar = self.MultiStatusBar(self.top) self.status_bar = self.MultiStatusBar(self.top)
self.status_bar.set_label('column', 'Col: ?', side=RIGHT) self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
......
...@@ -58,8 +58,8 @@ class FileList: ...@@ -58,8 +58,8 @@ class FileList:
if edit is not None and lineno is not None: if edit is not None and lineno is not None:
edit.gotoline(lineno) edit.gotoline(lineno)
def new(self): def new(self, filename=None):
return self.EditorWindow(self) return self.EditorWindow(self, filename)
def new_callback(self, event): def new_callback(self, event):
self.new() self.new()
......
...@@ -179,9 +179,15 @@ class IOBinding: ...@@ -179,9 +179,15 @@ class IOBinding:
self.filename_change_hook = hook self.filename_change_hook = hook
filename = None filename = None
dirname = None
def set_filename(self, filename): def set_filename(self, filename):
if filename and os.path.isdir(filename):
self.filename = None
self.dirname = filename
else:
self.filename = filename self.filename = filename
self.dirname = None
self.set_saved(1) self.set_saved(1)
if self.filename_change_hook: if self.filename_change_hook:
self.filename_change_hook() self.filename_change_hook()
...@@ -505,6 +511,8 @@ class IOBinding: ...@@ -505,6 +511,8 @@ class IOBinding:
def defaultfilename(self, mode="open"): def defaultfilename(self, mode="open"):
if self.filename: if self.filename:
return os.path.split(self.filename) return os.path.split(self.filename)
elif self.dirname:
return self.dirname, ""
else: else:
try: try:
pwd = os.getcwd() pwd = os.getcwd()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment