[Python-checkins] CVS: python/dist/src/Tools/idle PyShell.py,1.27,1.28
Guido van Rossum
guido@cnri.reston.va.us
Tue, 7 Mar 2000 13:51:51 -0500 (EST)
Update of /projects/cvsroot/python/dist/src/Tools/idle
In directory eric:/projects/python/develop/guido/src/Tools/idle
Modified Files:
PyShell.py
Log Message:
Override the Undo delegator to forbid any changes before the I/O mark.
It beeps if you try to insert or delete before the "iomark" mark.
This makes the shell less confusing for newbies.
Index: PyShell.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Tools/idle/PyShell.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** PyShell.py 2000/03/07 17:55:32 1.27
--- PyShell.py 2000/03/07 18:51:49 1.28
***************
*** 16,19 ****
--- 16,20 ----
from FileList import FileList
from ColorDelegator import ColorDelegator
+ from UndoDelegator import UndoDelegator
from OutputWindow import OutputWindow
from IdleConf import idleconf
***************
*** 128,131 ****
--- 129,154 ----
+ class ModifiedUndoDelegator(UndoDelegator):
+
+ # Forbid insert/delete before the I/O mark
+
+ def insert(self, index, chars, tags=None):
+ try:
+ if self.delegate.compare(index, "<", "iomark"):
+ self.delegate.bell()
+ return
+ except TclError:
+ pass
+ UndoDelegator.insert(self, index, chars, tags)
+
+ def delete(self, index1, index2=None):
+ try:
+ if self.delegate.compare(index1, "<", "iomark"):
+ self.delegate.bell()
+ return
+ except TclError:
+ pass
+ UndoDelegator.delete(self, index1, index2)
+
class ModifiedInterpreter(InteractiveInterpreter):
***************
*** 265,268 ****
--- 288,292 ----
# Override classes
ColorDelegator = ModifiedColorDelegator
+ UndoDelegator = ModifiedUndoDelegator
# Override menu bar specs