--- a/plugins/python/PythonEditor.py Fri Dec 16 22:54:24 2011 +0100
+++ b/plugins/python/PythonEditor.py Fri Dec 16 22:55:13 2011 +0100
@@ -571,6 +571,9 @@
# Edit Project Menu Functions
#-------------------------------------------------------------------------------
+ def RefreshFileMenu(self): def RefreshEditMenu(self):
undo, redo = self.Controler.GetBufferState()
self.EditMenu.Enable(wx.ID_UNDO, undo)
--- a/plugins/python/python.py Fri Dec 16 22:54:24 2011 +0100
+++ b/plugins/python/python.py Fri Dec 16 22:55:13 2011 +0100
@@ -2,6 +2,7 @@
from plugger import PlugTemplate, opjimg
+from PLCControler import UndoBuffer from PythonEditor import PythonEditorFrame
from xml.dom import minidom
@@ -10,88 +11,6 @@
PythonClasses = GenerateClassesFromXSD(os.path.join(os.path.dirname(__file__), "python_xsd.xsd"))
-#-------------------------------------------------------------------------------
-# Undo Buffer for PythonCode
-#-------------------------------------------------------------------------------
-Class implementing a buffer of changes made on the current editing model
- # Constructor initialising buffer
- def __init__(self, currentstate, issaved = False):
- # if current state is defined
- # Initialising buffer with currentstate at the first place
- for i in xrange(UNDO_BUFFER_LENGTH):
- self.Buffer.append(currentstate)
- self.Buffer.append(None)
- # Initialising index of state saved
- # Add a new state in buffer
- def Buffering(self, currentstate):
- self.CurrentIndex = (self.CurrentIndex + 1) % UNDO_BUFFER_LENGTH
- self.Buffer[self.CurrentIndex] = currentstate
- # Actualising buffer limits
- self.MaxIndex = self.CurrentIndex
- if self.MinIndex == self.CurrentIndex:
- # If the removed state was the state saved, there is no state saved in the buffer
- if self.LastSave == self.MinIndex:
- self.MinIndex = (self.MinIndex + 1) % UNDO_BUFFER_LENGTH
- self.MinIndex = max(self.MinIndex, 0)
- # Return current state of buffer
- return self.Buffer[self.CurrentIndex]
- # Change current state to previous in buffer and return new current state
- if self.CurrentIndex != self.MinIndex:
- self.CurrentIndex = (self.CurrentIndex - 1) % UNDO_BUFFER_LENGTH
- return self.Buffer[self.CurrentIndex]
- # Change current state to next in buffer and return new current state
- if self.CurrentIndex != self.MaxIndex:
- self.CurrentIndex = (self.CurrentIndex + 1) % UNDO_BUFFER_LENGTH
- return self.Buffer[self.CurrentIndex]
- # Return True if current state is the first in buffer
- return self.CurrentIndex == self.MinIndex
- # Return True if current state is the last in buffer
- return self.CurrentIndex == self.MaxIndex
- # Note that current state is saved
- def CurrentSaved(self):
- self.LastSave = self.CurrentIndex
- # Return True if current state is saved
- def IsCurrentSaved(self):
- return self.LastSave == self.CurrentIndex
class PythonCodeTemplate: