def checkIfOnKeyword(self): offset = self.getCaretPosition() currentPosition = offset startPosition = 0 endPosition = 0 if currentPosition > 0 and not Character.isLetter(String(self.getText(currentPosition, 1)).charAt(0)): currentPosition -= 1 while currentPosition > 0 and Character.isLetter(String(self.getText(currentPosition, 1)).charAt(0)): currentPosition -= 1 startPosition = currentPosition currentPosition = offset while currentPosition < self.document.getLength() and Character.isLetter(String(self.getText(currentPosition, 1)).charAt(0)): currentPosition += 1 endPosition = currentPosition keyword = self.getText(startPosition, endPosition - startPosition + 1) # the above selects more text than is needed sometimes, so we prune the # edges if keyword[0] == ' ': keyword = keyword[1:] if not keyword[len(keyword) - 1].isalpha(): keyword = keyword[:len(keyword) - 1] self.gui.UpdateToolbarHelp(keyword)
def checkIfOnKeyword(self): offset = self.getCaretPosition() currentPosition = offset startPosition = 0 endPosition = 0 if currentPosition > 0 and not Character.isLetter( String(self.getText(currentPosition, 1)).charAt(0)): currentPosition -= 1 while currentPosition > 0 and Character.isLetter( String(self.getText(currentPosition, 1)).charAt(0)): currentPosition -= 1 startPosition = currentPosition currentPosition = offset while currentPosition < self.document.getLength( ) and Character.isLetter( String(self.getText(currentPosition, 1)).charAt(0)): currentPosition += 1 endPosition = currentPosition keyword = self.getText(startPosition, endPosition - startPosition + 1) ## the above selects more text than is needed sometimes, so we prune the edges if keyword[0] == ' ': keyword = keyword[1:] if not keyword[len(keyword) - 1].isalpha(): keyword = keyword[:len(keyword) - 1] self.gui.UpdateToolbarHelp(keyword)
def key(self, e): # print >> sys.stderr, "Other Listener" if not self.visible: return code = e.getKeyCode() if code == KeyEvent.VK_ESCAPE: self.hide() elif code == KeyEvent.VK_ENTER or code == KeyEvent.VK_TAB: self.chooseSelected() e.consume() elif code == KeyEvent.VK_SPACE: # TODO for functions: choose the selected option, add parenthesis # and put the cursor between them. example: obj.function(^cursor_here) self.chooseSelected() elif code == KeyEvent.VK_PERIOD: self.chooseSelected() #e.consume() # This fails because the key listener in console gets it first elif code == KeyEvent.VK_LEFT_PARENTHESIS: self.chooseSelected() elif code == 8: # BACKSPACE if len(self.typed) == 0: self.hide() self.typed = self.typed[:-1] print >> sys.stderr, self.typed self.data = filter(self.originalData, self.typed) self.list.setListData(self.data) self.list.setSelectedIndex(0) elif code == KeyEvent.VK_UP: self.previous() # consume event to avoid history previous e.consume() elif code == KeyEvent.VK_DOWN: self.next() # consume event to avoid history next e.consume() else: char = e.getKeyChar() if Character.isJavaLetterOrDigit(char): self.typed += char self.data = filter(self.data, self.typed) self.list.setListData(self.data) self.list.setSelectedIndex(0)
def genQName(uri): """ Split URI in namespace URI and local name; return a ``(namespace_uri, local_name)`` pair. """ hadLetter = 0 i = len(uri) - 1 while i >= 0: if Character.isLetter(uri[i]) or uri[i] == '_': hadLetter = 1 elif Character.isDigit(uri[i]) or uri[i] in ('-', '.'): hadLetter = 0 else: if not hadLetter: raise Error("Cannot serialize graph because of " "unserializable property URI: %s" % uri) return (uri[:i + 1], uri[i + 1:]) i = i - 1
def key(self, e): # key listener #print "Other Listener" code = e.getKeyCode() #print 'keychar:',e.getKeyChar() if code == KeyEvent.VK_ESCAPE: self.hide() elif code == KeyEvent.VK_ENTER or code == KeyEvent.VK_TAB: self.chooseSelected() e.consume() elif code == 8: # BACKSPACE self.typed = self.typed[:-1] self.data = filter(self.originalData, self.typed) self.list.setListData(self.data) self.list.setSelectedIndex(0) elif code == KeyEvent.VK_UP: self.previous() # consume event to avoid history previous e.consume() elif code == KeyEvent.VK_DOWN: self.next() # consume event to avoid history next e.consume() else: char = e.getKeyChar() if Character.isJavaLetterOrDigit(char): self.typed += char self.data = filter(self.data, self.typed) self.list.setListData(self.data) self.list.setSelectedIndex(0)
foo, subfoo, subfoo2, n = Foo(), SubFoo(), SubFoo2(), N() for _v, _id in zip([foo, subfoo, subfoo2, n], ['foo', 'subfoo', 'subfoo2', 'n']): d[_v] = _id from java.lang import Long, Integer, Short, Character, Byte, Boolean, Double, Float, String from java.math import BigInteger values = [ 0, 0L, 0.0, 'c', "string", (), o, c, foo, subfoo, subfoo2, n, Object, Class, Foo, SubFoo, C, SubFoo2, N, Integer, Long(0), Integer(0), Short(0), Character('c'), Byte(0), Boolean(0), Double(0), Float(0), String("js"), BigInteger("0") ] def pp(v): inst = d.get(v, None) if inst is not None: return inst if hasattr(v, '__name__'): return v.__name__