Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions source/pythonConsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,11 @@ def historyMove(self, movement):
return True

RE_COMPLETE_UNIT = re.compile(r"[\w.]*$")

def complete(self):
textBeforeCursor = self.inputCtrl.GetRange(0, self.inputCtrl.GetSelection()[0])
try:
original = self.RE_COMPLETE_UNIT.search(self.inputCtrl.GetValue()).group(0)
original = self.RE_COMPLETE_UNIT.search(textBeforeCursor).group(0)
except AttributeError:
return False

Expand Down Expand Up @@ -373,16 +375,20 @@ def _insertCompletion(self, original, completed):
insert = completed[len(original):]
if not insert:
return
self.inputCtrl.SetValue(self.inputCtrl.GetValue() + insert)
inputCtrl = self.inputCtrl
selStartPos, selEndPos = inputCtrl.GetSelection()
prefix = inputCtrl.GetRange(0, selStartPos)
suffix = inputCtrl.GetRange(selEndPos, inputCtrl.GetLastPosition())
inputCtrl.SetValue(prefix + insert + suffix)
queueHandler.queueFunction(queueHandler.eventQueue, speech.speakText, insert)
self.inputCtrl.SetInsertionPointEnd()
inputCtrl.SetInsertionPoint(selStartPos + len(insert))

def onInputChar(self, evt):
key = evt.GetKeyCode()

if key == wx.WXK_TAB:
line = self.inputCtrl.GetValue()
if line and not line.isspace():
textBeforeCursor = self.inputCtrl.GetRange(0, self.inputCtrl.GetSelection()[0])
if textBeforeCursor and not textBeforeCursor.isspace():
if not self.complete():
wx.Bell()
return
Expand Down