From 7ff7d46a7e6b484193331546b1006f76003d3a4a Mon Sep 17 00:00:00 2001 From: komoto Date: Sat, 26 Jun 2021 04:55:42 +0900 Subject: [PATCH 1/5] Add Shell missing keywords Add the keyword 'finally' in Execute, to fix miss-indentation when pasting the following code: try: 1 finally: <-- indent error 0 Add the keyword 'with' to fix mis-indentation when typing: with xxx: | <-- incorrect auto-indentation in the next line --- wx/py/shell.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wx/py/shell.py b/wx/py/shell.py index fb319393..6423e9a3 100755 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -1087,7 +1087,7 @@ class Shell(editwindow.EditWindow): else: indent=previousLine[:(len(previousLine)-len(lstrip))] if pstrip[-1]==':' and \ - first_word in ['if','else','elif','for','while', + first_word in ['if','else','elif','for','while','with', 'def','class','try','except','finally']: indent+=' '*4 @@ -1416,7 +1416,8 @@ class Shell(editwindow.EditWindow): lstrip = line.lstrip() if line.strip() != '' and lstrip == line and \ lstrip[:4] not in ['else','elif'] and \ - lstrip[:6] != 'except': + lstrip[:6] != 'except' and \ + lstrip[:7] != 'finally': # New command. if command: # Add the previous command to the list. From 3d0b1df2879a01e27ea6d4d380d28efeea99913c Mon Sep 17 00:00:00 2001 From: komoto Date: Fri, 9 Jul 2021 16:18:24 +0900 Subject: [PATCH 2/5] Fix spelling error --- wx/lib/eventwatcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wx/lib/eventwatcher.py b/wx/lib/eventwatcher.py index ef4fc5b1..9e111867 100644 --- a/wx/lib/eventwatcher.py +++ b/wx/lib/eventwatcher.py @@ -250,7 +250,7 @@ class EventChooser(wx.Panel): self.doUpdate = False for position in range(self.lb.GetCount()): self.lb.Check(position, True) - index = self.lb.GetCliendData(position) + index = self.lb.GetClientData(position) self.watchList[index] = (self.watchList[index][0], check) self.lb.Refresh() self.doUpdate = True From 5d1b6e0d286d7ff62ea96f98113b0d418a2607c4 Mon Sep 17 00:00:00 2001 From: komoto Date: Thu, 29 Jul 2021 15:10:02 +0900 Subject: [PATCH 3/5] Fix Shell update event handler Rename the handler so that it does not override the base class EditWindow.OnUpdateUI. --- wx/py/shell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wx/py/shell.py b/wx/py/shell.py index 6423e9a3..5f7f446b 100755 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -305,7 +305,7 @@ class Shell(editwindow.EditWindow): # Assign handler for the context menu self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) - self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI) + self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateContextMenu) # add the option to not use the stock IDs; otherwise the context menu # may not work on Mac without adding the proper IDs to the menu bar @@ -1511,7 +1511,7 @@ class Shell(editwindow.EditWindow): menu = self.GetContextMenu() self.PopupMenu(menu) - def OnUpdateUI(self, evt): + def OnUpdateContextMenu(self, evt): id = evt.Id if id in (self.ID_CUT, self.ID_CLEAR): evt.Enable(self.CanCut()) From fd0560f256021f7890d9557474c31c5aa788c3da Mon Sep 17 00:00:00 2001 From: komoto Date: Thu, 29 Jul 2021 15:57:47 +0900 Subject: [PATCH 4/5] Add Shell EVT_UPDATE_UI handler for each id (revert) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateContextMenu) without specifing id triggers EVT_UPDATE_UI frequently. --- wx/py/shell.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/wx/py/shell.py b/wx/py/shell.py index 5f7f446b..31c47c04 100755 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -305,7 +305,7 @@ class Shell(editwindow.EditWindow): # Assign handler for the context menu self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) - self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateContextMenu) + ## self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateContextMenu) # add the option to not use the stock IDs; otherwise the context menu # may not work on Mac without adding the proper IDs to the menu bar @@ -337,6 +337,14 @@ class Shell(editwindow.EditWindow): self.Bind(wx.EVT_MENU, lambda evt: self.Undo(), id=self.ID_UNDO) self.Bind(wx.EVT_MENU, lambda evt: self.Redo(), id=self.ID_REDO) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanCut()), id=self.ID_CUT) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanCut()), id=self.ID_CLEAR) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanCopy()), id=self.ID_COPY) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanCopy()), id=frame.ID_COPY_PLUS) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanPaste()), id=self.ID_PASTE) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanPaste()), id=frame.ID_PASTE_PLUS) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanUndo()), id=self.ID_UNDO) + self.Bind(wx.EVT_UPDATE_UI, lambda evt: evt.Enable(self.CanRedo()), id=self.ID_REDO) # Assign handler for idle time. self.waiting = False @@ -1511,18 +1519,18 @@ class Shell(editwindow.EditWindow): menu = self.GetContextMenu() self.PopupMenu(menu) - def OnUpdateContextMenu(self, evt): - id = evt.Id - if id in (self.ID_CUT, self.ID_CLEAR): - evt.Enable(self.CanCut()) - elif id in (self.ID_COPY, frame.ID_COPY_PLUS): - evt.Enable(self.CanCopy()) - elif id in (self.ID_PASTE, frame.ID_PASTE_PLUS): - evt.Enable(self.CanPaste()) - elif id == self.ID_UNDO: - evt.Enable(self.CanUndo()) - elif id == self.ID_REDO: - evt.Enable(self.CanRedo()) +## def OnUpdateContextMenu(self, evt): +## id = evt.Id +## if id in (self.ID_CUT, self.ID_CLEAR): +## evt.Enable(self.CanCut()) +## elif id in (self.ID_COPY, frame.ID_COPY_PLUS): +## evt.Enable(self.CanCopy()) +## elif id in (self.ID_PASTE, frame.ID_PASTE_PLUS): +## evt.Enable(self.CanPaste()) +## elif id == self.ID_UNDO: +## evt.Enable(self.CanUndo()) +## elif id == self.ID_REDO: +## evt.Enable(self.CanRedo()) From d8a0f0e6391e23d72696321ba5bfed22fff0153d Mon Sep 17 00:00:00 2001 From: komoto Date: Tue, 14 Dec 2021 14:42:04 +0900 Subject: [PATCH 5/5] Remove comments and cleanup --- wx/py/shell.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/wx/py/shell.py b/wx/py/shell.py index 5ed4aa0a..cd74ed1b 100755 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -305,7 +305,6 @@ class Shell(editwindow.EditWindow): # Assign handler for the context menu self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) - ## self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateContextMenu) # add the option to not use the stock IDs; otherwise the context menu # may not work on Mac without adding the proper IDs to the menu bar @@ -1519,19 +1518,6 @@ class Shell(editwindow.EditWindow): menu = self.GetContextMenu() self.PopupMenu(menu) -## def OnUpdateContextMenu(self, evt): -## id = evt.Id -## if id in (self.ID_CUT, self.ID_CLEAR): -## evt.Enable(self.CanCut()) -## elif id in (self.ID_COPY, frame.ID_COPY_PLUS): -## evt.Enable(self.CanCopy()) -## elif id in (self.ID_PASTE, frame.ID_PASTE_PLUS): -## evt.Enable(self.CanPaste()) -## elif id == self.ID_UNDO: -## evt.Enable(self.CanUndo()) -## elif id == self.ID_REDO: -## evt.Enable(self.CanRedo()) -