mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
1. Prevent Undo before IOmark in PyShell.PyShell
2. Consolidate Undo code in EditorWindow.EditorWindow 3. Remove Formatting and Run menus from PyShell
This commit is contained in:
parent
0c08864fbb
commit
dc1e70987f
2 changed files with 22 additions and 13 deletions
|
@ -151,10 +151,8 @@ class EditorWindow:
|
||||||
text.bind("<<open-path-browser>>", self.open_path_browser)
|
text.bind("<<open-path-browser>>", self.open_path_browser)
|
||||||
|
|
||||||
self.set_status_bar()
|
self.set_status_bar()
|
||||||
|
|
||||||
vbar['command'] = text.yview
|
vbar['command'] = text.yview
|
||||||
vbar.pack(side=RIGHT, fill=Y)
|
vbar.pack(side=RIGHT, fill=Y)
|
||||||
|
|
||||||
text['yscrollcommand'] = vbar.set
|
text['yscrollcommand'] = vbar.set
|
||||||
fontWeight='normal'
|
fontWeight='normal'
|
||||||
if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'):
|
if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'):
|
||||||
|
@ -168,30 +166,34 @@ class EditorWindow:
|
||||||
|
|
||||||
self.per = per = self.Percolator(text)
|
self.per = per = self.Percolator(text)
|
||||||
if self.ispythonsource(filename):
|
if self.ispythonsource(filename):
|
||||||
self.color = color = self.ColorDelegator(); per.insertfilter(color)
|
self.color = color = self.ColorDelegator()
|
||||||
|
per.insertfilter(color)
|
||||||
##print "Initial colorizer"
|
##print "Initial colorizer"
|
||||||
else:
|
else:
|
||||||
##print "No initial colorizer"
|
##print "No initial colorizer"
|
||||||
self.color = None
|
self.color = None
|
||||||
self.undo = undo = self.UndoDelegator(); per.insertfilter(undo)
|
|
||||||
|
self.undo = undo = self.UndoDelegator()
|
||||||
|
per.insertfilter(undo)
|
||||||
|
text.undo_block_start = undo.undo_block_start
|
||||||
|
text.undo_block_stop = undo.undo_block_stop
|
||||||
|
undo.set_saved_change_hook(self.saved_change_hook)
|
||||||
|
|
||||||
|
# IOBinding implements file I/O and printing functionality
|
||||||
self.io = io = self.IOBinding(self)
|
self.io = io = self.IOBinding(self)
|
||||||
|
io.set_filename_change_hook(self.filename_change_hook)
|
||||||
|
|
||||||
#create the Recent Files submenu
|
#create the Recent Files submenu
|
||||||
self.menuRecentFiles=Menu(self.menubar)
|
self.menuRecentFiles=Menu(self.menubar)
|
||||||
self.menudict['file'].insert_cascade(3,label='Recent Files',
|
self.menudict['file'].insert_cascade(3,label='Recent Files',
|
||||||
underline=0,menu=self.menuRecentFiles)
|
underline=0,menu=self.menuRecentFiles)
|
||||||
self.UpdateRecentFilesList()
|
self.UpdateRecentFilesList()
|
||||||
|
|
||||||
text.undo_block_start = undo.undo_block_start
|
|
||||||
text.undo_block_stop = undo.undo_block_stop
|
|
||||||
undo.set_saved_change_hook(self.saved_change_hook)
|
|
||||||
io.set_filename_change_hook(self.filename_change_hook)
|
|
||||||
|
|
||||||
if filename:
|
if filename:
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
io.loadfile(filename)
|
io.loadfile(filename)
|
||||||
else:
|
else:
|
||||||
io.set_filename(filename)
|
io.set_filename(filename)
|
||||||
|
|
||||||
self.saved_change_hook()
|
self.saved_change_hook()
|
||||||
|
|
||||||
self.load_extensions()
|
self.load_extensions()
|
||||||
|
|
|
@ -450,9 +450,15 @@ class PyShell(OutputWindow):
|
||||||
ColorDelegator = ModifiedColorDelegator
|
ColorDelegator = ModifiedColorDelegator
|
||||||
UndoDelegator = ModifiedUndoDelegator
|
UndoDelegator = ModifiedUndoDelegator
|
||||||
|
|
||||||
# Override menu bar specs
|
# Override menus: Run and Format not desired in shell; add Debug
|
||||||
menu_specs = PyShellEditorWindow.menu_specs[:]
|
menu_specs = [
|
||||||
menu_specs.insert(len(menu_specs)-3, ("debug", "_Debug"))
|
("file", "_File"),
|
||||||
|
("edit", "_Edit"),
|
||||||
|
("debug", "_Debug"),
|
||||||
|
("settings", "_Settings"),
|
||||||
|
("windows", "_Windows"),
|
||||||
|
("help", "_Help"),
|
||||||
|
]
|
||||||
|
|
||||||
# New classes
|
# New classes
|
||||||
from IdleHistory import History
|
from IdleHistory import History
|
||||||
|
@ -825,6 +831,7 @@ class PyShell(OutputWindow):
|
||||||
self.console.write(s)
|
self.console.write(s)
|
||||||
self.text.mark_set("insert", "end-1c")
|
self.text.mark_set("insert", "end-1c")
|
||||||
self.set_line_and_column()
|
self.set_line_and_column()
|
||||||
|
self.io.reset_undo()
|
||||||
|
|
||||||
def resetoutput(self):
|
def resetoutput(self):
|
||||||
source = self.text.get("iomark", "end-1c")
|
source = self.text.get("iomark", "end-1c")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue