# HG changeset patch # User Laurent Bessard # Date 1371212368 -7200 # Node ID 7b9259945453d3e430c823690d3254d1253aeb0e # Parent 46425f3248b728e53c9c28758e71b0e2572d4aff Fixed bug with Copy/Paste in generated ST code Viewer diff -r 46425f3248b7 -r 7b9259945453 ProjectController.py --- a/ProjectController.py Fri Jun 14 11:45:56 2013 +0200 +++ b/ProjectController.py Fri Jun 14 14:19:28 2013 +0200 @@ -993,7 +993,7 @@ if self._IECCodeView is None: plc_file = self._getIECcodepath() - self._IECCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) + self._IECCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", self.AppFrame, None, instancepath=name) self._IECCodeView.SetTextSyntax("ALL") self._IECCodeView.SetKeywords(IEC_KEYWORDS) try: @@ -1013,7 +1013,7 @@ if self._IECRawCodeView is None: controler = MiniTextControler(self._getIECrawcodepath(), self) - self._IECRawCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) + self._IECRawCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", self.AppFrame, controler, instancepath=name) self._IECRawCodeView.SetTextSyntax("ALL") self._IECRawCodeView.SetKeywords(IEC_KEYWORDS) self._IECRawCodeView.RefreshView() diff -r 46425f3248b7 -r 7b9259945453 editors/IECCodeViewer.py --- a/editors/IECCodeViewer.py Fri Jun 14 11:45:56 2013 +0200 +++ b/editors/IECCodeViewer.py Fri Jun 14 14:19:28 2013 +0200 @@ -8,6 +8,10 @@ TextViewer.__del__(self) if getattr(self, "_OnClose"): self._OnClose(self) - + + def Paste(self): + if self.Controler is not None: + TextViewer.Paste(self) + def Search(self, criteria): return [((self.TagName, "body", 0),) + result for result in TestTextElement(self.Editor.GetText(), criteria)] \ No newline at end of file diff -r 46425f3248b7 -r 7b9259945453 editors/TextViewer.py --- a/editors/TextViewer.py Fri Jun 14 11:45:56 2013 +0200 +++ b/editors/TextViewer.py Fri Jun 14 14:19:28 2013 +0200 @@ -31,7 +31,7 @@ from graphics.GraphicCommons import ERROR_HIGHLIGHT, SEARCH_RESULT_HIGHLIGHT, REFRESH_HIGHLIGHT_PERIOD from plcopen.structures import ST_BLOCK_START_KEYWORDS, ST_BLOCK_END_KEYWORDS, IEC_BLOCK_START_KEYWORDS, IEC_BLOCK_END_KEYWORDS, LOCATIONDATATYPES from EditorPanel import EditorPanel -from controls.CustomStyledTextCtrl import CustomStyledTextCtrl, faces, GetCursorPos +from controls.CustomStyledTextCtrl import CustomStyledTextCtrl, faces, GetCursorPos, NAVIGATION_KEYS #------------------------------------------------------------------------------- # Textual programs Viewer class @@ -722,8 +722,9 @@ event.Skip() def OnUpdateUI(self, event): - if self.ParentWindow: - self.ParentWindow.SetCopyBuffer(self.Editor.GetSelectedText(), True) + selected = self.Editor.GetSelectedText() + if self.ParentWindow and selected != "": + self.ParentWindow.SetCopyBuffer(selected, True) event.Skip() def Cut(self): @@ -794,11 +795,12 @@ self.ResetSearchResults() def OnKeyDown(self, event): + key = event.GetKeyCode() if self.Controler is not None: if self.Editor.CallTipActive(): self.Editor.CallTipCancel() - key = event.GetKeyCode() + key_handled = False line = self.Editor.GetCurrentLine() @@ -852,6 +854,8 @@ key_handled = True if not key_handled: event.Skip() + elif key in NAVIGATION_KEYS: + event.Skip() def OnKillFocus(self, event): self.Editor.AutoCompCancel()