summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-06-05 02:34:04 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2003-06-05 02:34:04 (GMT)
commitd2f4861a0b52a2af5ea3395267a5c56541352f8f (patch)
treecea0a424c203fc971d91aaa8626593612707d913 /Lib/idlelib
parenta1045567e01027b3a1b531181329cb11fae7d9f0 (diff)
downloadcpython-d2f4861a0b52a2af5ea3395267a5c56541352f8f.zip
cpython-d2f4861a0b52a2af5ea3395267a5c56541352f8f.tar.gz
cpython-d2f4861a0b52a2af5ea3395267a5c56541352f8f.tar.bz2
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
Diffstat (limited to 'Lib/idlelib')
-rw-r--r--Lib/idlelib/EditorWindow.py9
-rw-r--r--Lib/idlelib/FileList.py4
-rw-r--r--Lib/idlelib/IOBinding.py16
3 files changed, 21 insertions, 8 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index fcb1612..2303537 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -139,7 +139,7 @@ class EditorWindow:
flist.inversedict[self] = key
if key:
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("<<open-class-browser>>", self.open_class_browser)
text.bind("<<open-path-browser>>", self.open_path_browser)
@@ -182,7 +182,7 @@ class EditorWindow:
self.UpdateRecentFilesList()
if filename:
- if os.path.exists(filename):
+ if os.path.exists(filename) and not os.path.isdir(filename):
io.loadfile(filename)
else:
io.set_filename(filename)
@@ -210,6 +210,11 @@ class EditorWindow:
self.extensions['AutoIndent'].set_indentation_params(
self.ispythonsource(filename))
+ def new_callback(self, event):
+ dirname, basename = self.io.defaultfilename()
+ self.flist.new(dirname)
+ return "break"
+
def set_status_bar(self):
self.status_bar = self.MultiStatusBar(self.top)
self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py
index e01ce3c..7a46afa 100644
--- a/Lib/idlelib/FileList.py
+++ b/Lib/idlelib/FileList.py
@@ -58,8 +58,8 @@ class FileList:
if edit is not None and lineno is not None:
edit.gotoline(lineno)
- def new(self):
- return self.EditorWindow(self)
+ def new(self, filename=None):
+ return self.EditorWindow(self, filename)
def new_callback(self, event):
self.new()
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index cd2638c..e207750 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -179,12 +179,18 @@ class IOBinding:
self.filename_change_hook = hook
filename = None
+ dirname = None
def set_filename(self, filename):
- self.filename = filename
- self.set_saved(1)
- if self.filename_change_hook:
- self.filename_change_hook()
+ if filename and os.path.isdir(filename):
+ self.filename = None
+ self.dirname = filename
+ else:
+ self.filename = filename
+ self.dirname = None
+ self.set_saved(1)
+ if self.filename_change_hook:
+ self.filename_change_hook()
def open(self, event=None, editFile=None):
if self.editwin.flist:
@@ -505,6 +511,8 @@ class IOBinding:
def defaultfilename(self, mode="open"):
if self.filename:
return os.path.split(self.filename)
+ elif self.dirname:
+ return self.dirname, ""
else:
try:
pwd = os.getcwd()