def onMouseDwell(self, args): '''Show a call tip window about the current content of a selected variable''' #if self.bufferActive or self.interp.active(): return #if editor.callTipActive(): return pos = editor.positionFromPoint(args['x'], args['y']) self.showCalltip(pos)
def onTimerMiddleButton(self): middleButton = windll.user32.GetKeyState(VK_MBUTTON) if self.middleButton != middleButton and (middleButton - (middleButton & 1)) != 0: x, y = GetCursorPos() hFore = windll.user32.GetForegroundWindow() hPoint = windll.user32.WindowFromPoint(x, y) if hPoint == hFore: hPoint = windll.user32.ChildWindowFromPoint(hFore, x, y) hSelf = self.windowHandle x0, y0, x1, y1 = GetWindowRect(hPoint) if x0 <= x <= x1 and y0 <= y <= y1 and hSelf == hFore: editor.grabFocus() pos = editor.positionFromPoint(x - x0, y - y0) iLineClick = editor.lineFromPosition(pos) iStart = editor.getSelectionStart() iEnd = editor.getSelectionEnd() iLineStart = editor.lineFromPosition(iStart) iLineEnd = editor.lineFromPosition(iEnd) if iStart != iEnd and iLineStart <= iLineClick <= iLineEnd: self.runCodeAtCursor(moveCursor=False, onlyInsideCodeLines=True) elif 0 <= pos < editor.getLength(): self.runCodeAtCursor(moveCursor=False, nonSelectedLine=iLineClick, onlyInsideCodeLines=True) self.middleButton = middleButton threading.Timer(self.tTimerMiddleButton, self.onTimerMiddleButton).start()
def callback_scintillawrapper_int_void_position(self, args): x = editor.pointXFromPosition(6) # X position of the W y = editor.pointYFromPosition(6) position = editor.positionFromPoint(x, y) self.assertEqual(position, 6) self.callbackCalled = True
def test_scintillawrapper_position_int_int(self): editor.write('Hello World'); x = editor.pointXFromPosition(6) # X position of the W y = editor.pointYFromPosition(6) position = editor.positionFromPoint(x, y) self.assertEqual(position, 6)
def test_scintillawrapper_int_void_position(self): # This test is actually identical to position_int_int # That test is for positionFromPoint(), this is for pointXFromPosition() # I'm leaving this in, so we've definitely got a covering test for int_void_position editor.write('Hello World'); x = editor.pointXFromPosition(6) # X position of the W y = editor.pointYFromPosition(6) position = editor.positionFromPoint(x, y) self.assertEqual(position, 6)
def onMouseDwell(self, args): '''Show a call tip window about the current content of a selected variable''' if self.bufferBusy or self.interp.kernelBusy.isSet(): return if editor.callTipActive(): return p = editor.positionFromPoint(args['x'], args['y']) iStart = editor.getSelectionStart() iEnd = editor.getSelectionEnd() if iEnd != iStart and iStart <= p <= iEnd: if self.popupForSelectedExpression and iEnd - iStart > 1: expression = editor.getTextRange(iStart, iEnd) if expression == 'False': self.activeCalltip = False editor.callTipShow(iStart, 'set to True') elif expression == 'True': self.activeCalltip = True editor.callTipShow(iStart, 'set to False') elif not '\n' in expression: ret = self.interp.getCallTip(None, expression) if ret: element, nHighlight, calltip = ret self.activeCalltip = 'doc' editor.callTipShow(iStart, ''.join(calltip)) editor.callTipSetHlt(0, int(nHighlight)) else: iLineStart = editor.positionFromLine( editor.lineFromPosition(iStart)) var = editor.getTextRange(iStart, iEnd) line = editor.getTextRange(iLineStart, iEnd) if var == '.': autoCompleteList = self.interp.autoCompleteObject( self.getUncompleteLine(iStart + 1)) if autoCompleteList: editor.autoCSetSeparator(ord('\t')) editor.autoCSetIgnoreCase(False) editor.autoCSetCaseInsensitiveBehaviour(False) editor.autoCSetOrder(0) editor.autoCSetDropRestOfWord(True) editor.autoCShow(0, autoCompleteList) else: ret = self.interp.getCallTip(line, var) if ret: element, nHighlight, calltip = ret if element == var == 'False': self.activeCalltip = False editor.callTipShow(iStart, 'set to True') elif element == var == 'True': self.activeCalltip = True editor.callTipShow(iStart, 'set to False') else: self.activeCalltip = 'doc' editor.callTipShow(iStart, ''.join(calltip)) editor.callTipSetHlt(0, int(nHighlight)) elif self.popupForUnselectedVariable and iStart == iEnd and p >= 0: iLine = editor.lineFromPosition(p) line = editor.getLine(iLine) iLineStart = editor.positionFromLine(iLine) posInLine = p - iLineStart iWordEnd = 0 for iWordStart in range(posInLine, -1, -1): s = line[iWordStart] if not ('a' <= s <= 'z' or 'A' <= s <= 'Z' or '0' <= s <= '9' or s == '_'): iWordStart += 1 break if iWordStart <= posInLine: for iWordEnd in range(posInLine + 1, len(line)): s = line[iWordEnd] if not ('a' <= s <= 'z' or 'A' <= s <= 'Z' or '0' <= s <= '9' or s == '_'): iWordEnd -= 1 break var = line[iWordStart:iWordEnd + 1] if var: var = line[iWordStart:iWordEnd + 1] ret = self.interp.getCallTip(line[0:iWordEnd + 1], var) pos = iLineStart + iWordStart if ret: element, nHighlight, calltip = ret self.activeCalltip = 'doc' editor.callTipShow(pos, ''.join(calltip)) editor.callTipSetHlt(0, int(nHighlight))