From efa85f17987ecdbbc69dd57d1609ce323ac37a39 Mon Sep 17 00:00:00 2001 From: komoto Date: Thu, 12 May 2022 23:24:14 +0900 Subject: [PATCH 1/4] Fix OnHistorySearch range+ error Fix TypeError: unsupported operand type(s) for +: 'range' and 'range' --- wx/py/shell.py | 4 ++-- wx/py/sliceshell.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wx/py/shell.py b/wx/py/shell.py index 0226f131..ce5981fa 100755 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -854,8 +854,8 @@ class Shell(editwindow.EditWindow): or (self.historyIndex >= len(self.history)-2): searchOrder = range(len(self.history)) else: - searchOrder = range(self.historyIndex+1, len(self.history)) + \ - range(self.historyIndex) + ls = list(range(len(self.history))) + searchOrder = ls[self.historyIndex+1:] + ls[:self.historyIndex] for i in searchOrder: command = self.history[i] if command[:len(searchText)] == searchText: diff --git a/wx/py/sliceshell.py b/wx/py/sliceshell.py index 3648001a..1bbc643d 100755 --- a/wx/py/sliceshell.py +++ b/wx/py/sliceshell.py @@ -2270,8 +2270,8 @@ class SlicesShell(editwindow.EditWindow): or (self.historyIndex >= len(self.history)-2): searchOrder = range(len(self.history)) else: - searchOrder = range(self.historyIndex+1, len(self.history)) + \ - range(self.historyIndex) + ls = list(range(len(self.history))) + searchOrder = ls[self.historyIndex+1:] + ls[:self.historyIndex] for i in searchOrder: command = self.history[i] if command[:len(searchText)] == searchText: From 3381f5bfb46a1f5ed60a44aebf2f4daf5cdc174f Mon Sep 17 00:00:00 2001 From: komoto Date: Thu, 12 May 2022 23:47:22 +0900 Subject: [PATCH 2/4] Override SetSelection as a temporary patch Patch for miss-insertion position when from_ > to_. This is needed until the stc.StyledText.SetSelection bug is fixed. --- wx/py/shell.py | 9 ++++++++- wx/py/sliceshell.py | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/wx/py/shell.py b/wx/py/shell.py index ce5981fa..17e3dec7 100755 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -1518,7 +1518,14 @@ class Shell(editwindow.EditWindow): menu = self.GetContextMenu() self.PopupMenu(menu) - + def SetSelection(self, from_, to_): + """Selects the text starting at the first position up to + (but not including) the character at the last position. + """ + # (override) Patch for miss-insertion position when from_ > to_. + # Note: This is needed until the stc SetSelection bug is fixed. + self.SetAnchor(from_) + self.SetCurrentPos(to_) ## NOTE: The DnD of file names is disabled until we can figure out how diff --git a/wx/py/sliceshell.py b/wx/py/sliceshell.py index 1bbc643d..f8948012 100755 --- a/wx/py/sliceshell.py +++ b/wx/py/sliceshell.py @@ -3751,6 +3751,14 @@ class SlicesShell(editwindow.EditWindow): """Return True if contents have changed.""" return self.GetModify() or self.NeedsCheckForSave + def SetSelection(self, from_, to_): + """Selects the text starting at the first position up to + (but not including) the character at the last position. + """ + # (override) Patch for miss-insertion position when from_ > to_. + # Note: This is needed until the stc SetSelection bug is fixed. + self.SetAnchor(from_) + self.SetCurrentPos(to_) ## NOTE: The DnD of file names is disabled until we can figure out how From 85466c87b8007bffcec20d1d518de7894d22943b Mon Sep 17 00:00:00 2001 From: komoto Date: Fri, 20 May 2022 13:09:07 +0900 Subject: [PATCH 3/4] Revert "Override SetSelection as a temporary patch" Better to override editwindow --- wx/py/shell.py | 9 +-------- wx/py/sliceshell.py | 8 -------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/wx/py/shell.py b/wx/py/shell.py index 17e3dec7..ce5981fa 100755 --- a/wx/py/shell.py +++ b/wx/py/shell.py @@ -1518,14 +1518,7 @@ class Shell(editwindow.EditWindow): menu = self.GetContextMenu() self.PopupMenu(menu) - def SetSelection(self, from_, to_): - """Selects the text starting at the first position up to - (but not including) the character at the last position. - """ - # (override) Patch for miss-insertion position when from_ > to_. - # Note: This is needed until the stc SetSelection bug is fixed. - self.SetAnchor(from_) - self.SetCurrentPos(to_) + ## NOTE: The DnD of file names is disabled until we can figure out how diff --git a/wx/py/sliceshell.py b/wx/py/sliceshell.py index f8948012..1bbc643d 100755 --- a/wx/py/sliceshell.py +++ b/wx/py/sliceshell.py @@ -3751,14 +3751,6 @@ class SlicesShell(editwindow.EditWindow): """Return True if contents have changed.""" return self.GetModify() or self.NeedsCheckForSave - def SetSelection(self, from_, to_): - """Selects the text starting at the first position up to - (but not including) the character at the last position. - """ - # (override) Patch for miss-insertion position when from_ > to_. - # Note: This is needed until the stc SetSelection bug is fixed. - self.SetAnchor(from_) - self.SetCurrentPos(to_) ## NOTE: The DnD of file names is disabled until we can figure out how From de5abf4219be0acbde96932e0b1e5825e8802ea2 Mon Sep 17 00:00:00 2001 From: komoto Date: Fri, 20 May 2022 13:20:48 +0900 Subject: [PATCH 4/4] Override editwindow SetSelection as a temporary patch Better to override editwindow (a common parent of shell and sliceshell) --- wx/py/editwindow.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wx/py/editwindow.py b/wx/py/editwindow.py index 99b0279e..fcaef992 100644 --- a/wx/py/editwindow.py +++ b/wx/py/editwindow.py @@ -297,3 +297,12 @@ class EditWindow(stc.StyledTextCtrl): # show and select the found text self.ShowPosition(loc) self.SetSelection(loc, loc + len(findstring)) + + def SetSelection(self, from_, to_): + """Selects the text starting at the first position up to + (but not including) the character at the last position. + """ + # (override) Patch for miss-insertion position when from_ > to_. + # Note: This is needed until the stc SetSelection bug is fixed. + self.SetAnchor(from_) + self.SetCurrentPos(to_)