Пример #1
0
	def waitingSend(self, text, vName):
		text = GParser().cleanText(text)
		blocks = GParser().getCommandBlocks(text)
		try:		
			for msg in blocks:
				while msg[0] in (' ', '\n', '\t'):
					msg = msg[1:]
					
				if msg == "":
					continue
				
				msg = msg.replace('\n\r', '\n').replace(chr(0x2028), '\n').replace(chr(0x2029), '\n')
				txts = msg.split('\n')
				
				for txt in txts:
					if txt == "" or txt.isspace():
						continue

					txt = txt.encode('utf-8')
					self.sock.send(txt)
					self.sock.recv(2048)
			
			# Ao final da gravação o avatar envia mais uma mensagem
			self.sock.recv(2048)
			self.sender.finishedRecording.emit(vName)
			
		except:
			print("Não há conexação com o servidor")
Пример #2
0
 def send(self, text):
     text = GParser().cleanText(text)
     blocks = GParser().getCommandBlocks(text)
     try:
         i = 0
         for msg in blocks:
             if msg[0] in (' ', '\n', '\t'):
                 msg = msg[1:]
             i += 1
             self.sock.send(msg.encode('utf-8'))
             self.sock.recv(2048)
     except:
         print("Não há conexação com o servidor")
Пример #3
0
    def inputMethodEvent(self, event):
        commitString = event.commitString()
        preeditString = event.preeditString()

        # Se for uma tecla morta que não invoca o keyPressEvent
        # cria o evento na mão já com o caractere em maiúsculo
        if commitString.upper() in GParser().getAccentedCharacters():
            newEvent = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
                                       QtCore.Qt.Key_Any, QtCore.Qt.NoModifier,
                                       commitString.upper())
            self.keyPressEvent(newEvent)
        else:
            super().inputMethodEvent(event)
Пример #4
0
    def __init__(self, clScheme, parent=None):
        QtWidgets.QTextEdit.__init__(self, parent)
        self.completer = GCompleter(GParser().getAlphabet())
        self.completer.setWidget(self)
        self.completer.insertText.connect(self.insertCompletion)
        self.pressed = {}
        self.onDeadKey = False

        self.highlighter = GSyntaxHighlighter(self)

        self.clScheme = clScheme

        self.completionEnd = " "

        self.setAttribute(QtCore.Qt.WA_InputMethodEnabled)
Пример #5
0
    def insertCompletion(self, completion):
        tc = self.textCursor()
        lc = self.textCursor()

        tc.movePosition(QtGui.QTextCursor.EndOfWord, tc.MoveAnchor)
        tc.movePosition(QtGui.QTextCursor.StartOfWord, tc.KeepAnchor)

        lc.movePosition(QtGui.QTextCursor.StartOfWord, lc.MoveAnchor)
        lc.movePosition(QtGui.QTextCursor.Left, lc.KeepAnchor)
        lc = lc.selectedText()
        if lc == '<':
            tc.movePosition(QtGui.QTextCursor.Left, tc.KeepAnchor)

        if completion in GParser().keywords():
            tc.insertText(completion)
        else:
            tc.insertText(completion + self.completionEnd)
        self.setTextCursor(tc)
        self.completer.popup().hide()