+ def GetContextMenu(self):
+ """
+ Create and return a context menu for the shell.
+ This is used instead of the scintilla default menu
+ in order to correctly respect our immutable buffer.
+ """
+ menu = wx.Menu()
+ menu.Append(wx.ID_UNDO, "Undo")
+ menu.Append(wx.ID_REDO, "Redo")
+
+ menu.AppendSeparator()
+
+ menu.Append(wx.ID_CUT, "Cut")
+ menu.Append(wx.ID_COPY, "Copy")
+ menu.Append(frame.ID_COPY_PLUS, "Copy Plus")
+ menu.Append(wx.ID_PASTE, "Paste")
+ menu.Append(frame.ID_PASTE_PLUS, "Paste Plus")
+ menu.Append(wx.ID_CLEAR, "Clear")
+
+ menu.AppendSeparator()
+
+ menu.Append(wx.ID_SELECTALL, "Select All")
+ return menu
+
+ def OnContextMenu(self, evt):
+ menu = self.GetContextMenu()
+ self.PopupMenu(menu)
+
+ def OnUpdateUI(self, evt):
+ id = evt.Id
+ if id in (wx.ID_CUT, wx.ID_CLEAR):
+ evt.Enable(self.CanCut())
+ elif id in (wx.ID_COPY, frame.ID_COPY_PLUS):
+ evt.Enable(self.CanCopy())
+ elif id in (wx.ID_PASTE, frame.ID_PASTE_PLUS):
+ evt.Enable(self.CanPaste())
+ elif id == wx.ID_UNDO:
+ evt.Enable(self.CanUndo())
+ elif id == wx.ID_REDO:
+ evt.Enable(self.CanRedo())
+
+