Skip to content

Commit

Permalink
Python Console: Jump to previous/next result (#9784)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienCochuyt committed Jun 23, 2019
1 parent 40bef37 commit 0970b28
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions source/pythonConsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def __init__(self, parent):
# Even the most recent line has a position in the history, so initialise with one blank line.
self.inputHistory = [""]
self.inputHistoryPos = 0
self.outputPositions = [0]

def onActivate(self, evt):
if evt.GetActive():
Expand Down Expand Up @@ -225,6 +226,7 @@ def execute(self):
self.inputHistory.append("")
self.inputHistoryPos = len(self.inputHistory) - 1
self.inputCtrl.ChangeValue("")
self.outputPositions.append(self.outputCtrl.GetInsertionPoint())

def historyMove(self, movement):
newIndex = self.inputHistoryPos + movement
Expand Down Expand Up @@ -349,6 +351,29 @@ def onOutputChar(self, evt):
if key == wx.WXK_F6:
self.inputCtrl.SetFocus()
return
if evt.ControlDown() and not evt.ShiftDown():
if key == wx.WXK_UP:
cur = self.outputCtrl.GetInsertionPoint()
for pos in reversed(self.outputPositions):
if pos < cur:
self.outputCtrl.SetInsertionPoint(pos)
break
else:
# Translators: A message reported when there is no next
# result in the Python Console.
speech.speakMessage(_("Top"))
return
if key == wx.WXK_DOWN:
cur = self.outputCtrl.GetInsertionPoint()
for pos in self.outputPositions:
if pos > cur:
self.outputCtrl.SetInsertionPoint(pos)
break
else:
# Translators: A message reported when there is no previous
# result in the Python Console.
speech.speakMessage(_("Bottom"))
return
evt.Skip()

def initialize():
Expand Down

0 comments on commit 0970b28

Please sign in to comment.