Пример #1
0
 def keyPressEvent(self, ev):
     if ev.key() == Qt.Key_X and ev.modifiers() == Qt.AltModifier:
         if self.replace_possible_unicode_sequence():
             ev.accept()
             return
     QPlainTextEdit.keyPressEvent(self, ev)
     if (ev.key() == Qt.Key_Semicolon or ';' in unicode(ev.text())) and tprefs['replace_entities_as_typed'] and self.syntax == 'html':
         self.replace_possible_entity()
Пример #2
0
 def keyPressEvent(self, ev):
     if ev.key() == Qt.Key_X and ev.modifiers() == Qt.AltModifier:
         if self.replace_possible_unicode_sequence():
             ev.accept()
             return
     QPlainTextEdit.keyPressEvent(self, ev)
     if (ev.key() == Qt.Key_Semicolon or ';' in unicode(ev.text(
     ))) and tprefs['replace_entities_as_typed'] and self.syntax == 'html':
         self.replace_possible_entity()
Пример #3
0
		def keyPressEvent(self, e):
		
			"""
			Captures keypresses to implement selection indentation
			and auto indentation
			
			Arguments:
			e -- a keypress even
			"""			

			# Process the Alt + A shortcut to apply changes
			if e.key() == QtCore.Qt.Key_A and e.modifiers() == QtCore.Qt.AltModifier:
				self.editor.apply.clicked.emit(True)
				return
				
			if e.key() not in range(QtCore.Qt.Key_Home, QtCore.Qt.Key_Direction_R):		
				self.editor.setModified(True)

			c = self.textCursor()			
			if not c.hasSelection():
			
				# Auto indent after a return
				if e.key() == QtCore.Qt.Key_Return and c.block().length() > 0:					
					s = unicode(c.block().text())
					n_tab = 0
					self.insertPlainText("\n")
					if len(s) > 0:
						while len(s) > 0 and s[0] == "\t":
							s = s[1:]
							self.insertPlainText("\t")				
					e.ignore()
					self.setFocus()					
					return																									
																			
			# Selection indent/ unindent
			if e.key() == QtCore.Qt.Key_Tab:
				if e.modifiers() == QtCore.Qt.MetaModifier:
					self.unindent()
					e.ignore()
					self.setFocus()
					return					
				elif c.hasSelection():
					self.indent()
					e.ignore()
					self.setFocus()
					return
			
			self.setFocus()	
			QPlainTextEdit.keyPressEvent(self, e)
Пример #4
0
 def keyPressEvent(self, ev):
     if ev.key() == Qt.Key_X and ev.modifiers() == Qt.AltModifier:
         if self.replace_possible_unicode_sequence():
             ev.accept()
             return
     if ev.key() == Qt.Key_Insert:
         self.setOverwriteMode(self.overwriteMode() ^ True)
         ev.accept()
         return
     QPlainTextEdit.keyPressEvent(self, ev)
     if (
         (ev.key() == Qt.Key_Semicolon or ";" in unicode(ev.text()))
         and tprefs["replace_entities_as_typed"]
         and self.syntax == "html"
     ):
         self.replace_possible_entity()
Пример #5
0
        def keyPressEvent(self, e):
            """
			Capture keypresses to implement selection indentation
			and auto indentation
			"""

            # Process the Alt + A shortcut to apply changes
            if e.key() == QtCore.Qt.Key_A and e.modifiers(
            ) == QtCore.Qt.AltModifier:
                self.editor.apply.clicked.emit(True)
                return

            if e.key() not in range(QtCore.Qt.Key_Home,
                                    QtCore.Qt.Key_Direction_R):
                self.editor.setModified(True)

            c = self.textCursor()
            if not c.hasSelection():

                # Auto indent after a return
                if e.key() == QtCore.Qt.Key_Return and c.block().length() > 0:
                    s = str(c.block().text())
                    n_tab = 0
                    self.insertPlainText("\n")
                    if len(s) > 0:
                        while len(s) > 0 and s[0] == "\t":
                            s = s[1:]
                            self.insertPlainText("\t")
                    e.ignore()
                    self.setFocus()
                    return

            # Selection indent/ unindent
            if e.key() == QtCore.Qt.Key_Tab:
                if e.modifiers() == QtCore.Qt.MetaModifier:
                    self.unindent()
                    e.ignore()
                    self.setFocus()
                    return
                elif c.hasSelection():
                    self.indent()
                    e.ignore()
                    self.setFocus()
                    return

            self.setFocus()
            QPlainTextEdit.keyPressEvent(self, e)
Пример #6
0
 def keyPressEvent(self, ev):
     QPlainTextEdit.keyPressEvent(self, ev)
     if (ev.key() == Qt.Key_Semicolon or ';' in unicode(ev.text())) and tprefs['replace_entities_as_typed'] and self.syntax == 'html':
         self.replace_possible_entity()