Example #1
0
 def keyPressEvent(self, ev):
     super(View, self).keyPressEvent(ev)
     
     if metainfo.info(self.document()).auto_indent:
         # run the indenter on Return or when the user entered a dedent token.
         import indent
         cursor = self.textCursor()
         if ev.text() == '\r' or (ev.text() in ('}', '#', '>') and indent.indentable(cursor)):
             indent.auto_indent_block(cursor.block())
             # fix subsequent vertical moves
             cursor.setPosition(cursor.position())
             self.setTextCursor(cursor)
Example #2
0
    def keyPressEvent(self, ev):
        super(View, self).keyPressEvent(ev)

        if metainfo.info(self.document()).auto_indent:
            # run the indenter on Return or when the user entered a dedent token.
            import indent
            cursor = self.textCursor()
            if ev.text() == '\r' or (ev.text() in ('}', '#', '>')
                                     and indent.indentable(cursor)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)
Example #3
0
 def keyPressEvent(self, ev):
     if homekey.handle(self, ev):
         return
     super(View, self).keyPressEvent(ev)
     
     if metainfo.info(self.document()).auto_indent:
         # run the indenter on Return or when the user entered a dedent token.
         import indent
         cursor = self.textCursor()
         if ev.text() == '\r' or (ev.text() in ('}', '#', '>') and indent.indentable(cursor)):
             with cursortools.compress_undo(cursor, True):
                 indent.auto_indent_block(cursor.block())
             # keep the cursor at the indent position on vertical move
             cursor = self.textCursor()
             pos = cursor.position()
             cursor.setPosition(cursor.block().position()) # move horizontal
             cursor.setPosition(pos) # move back to position
             self.setTextCursor(cursor)
Example #4
0
    def keyPressEvent(self, ev):
        """Reimplemented to perform actions after a key has been pressed.

        Currently handles:

        - indent change on Enter, }, # or >

        """
        super(View, self).keyPressEvent(ev)

        if metainfo.info(self.document()).auto_indent:
            # run the indenter on Return or when the user entered a dedent token.
            import indent
            cursor = self.textCursor()
            if ev.text() == '\r' or (ev.text() in ('}', '#', '>') and indent.indentable(cursor)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)
Example #5
0
    def keyPressEvent(self, ev):
        """Reimplemented to perform actions after a key has been pressed.
        
        Currently handles:
        
        - indent change on Enter, }, # or >
        
        """
        super(View, self).keyPressEvent(ev)

        if metainfo.info(self.document()).auto_indent:
            # run the indenter on Return or when the user entered a dedent token.
            import indent
            cursor = self.textCursor()
            if ev.text() == '\r' or (ev.text() in ('}', '#', '>')
                                     and indent.indentable(cursor)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)
Example #6
0
    def keyPressEvent(self, ev):
        """Reimplemented to perform actions after a key has been pressed.

        Currently handles:

        - indent change on Enter, }, # or >
        
        - update the tooltip info when Ctrl is pressed

        """
        super(View, self).keyPressEvent(ev)
        if ev.key() == Qt.Key_Control and self.include_target:
            self.viewport().setCursor(Qt.PointingHandCursor)
        if metainfo.info(self.document()).auto_indent:
            # run the indenter on Return or when the user entered a dedent token.
            import indent
            cursor = self.textCursor()
            if ev.text() == '\r' or (ev.text() in ('}', '#', '>') and indent.indentable(cursor)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)
Example #7
0
    def keyPressEvent(self, ev):
        """Reimplemented to perform actions after a key has been pressed.

        Currently handles:

        - indent change on Enter, }, # or >
        
        - update the tooltip info when Ctrl is pressed

        """
        super(View, self).keyPressEvent(ev)
        if ev.key() == Qt.Key_Control and self.include_target:
            self.viewport().setCursor(Qt.PointingHandCursor)
        if metainfo.info(self.document()).auto_indent:
            # run the indenter on Return or when the user entered a dedent token.
            import indent
            cursor = self.textCursor()
            if ev.text() == '\r' or (ev.text() in ('}', '#', '>')
                                     and indent.indentable(cursor)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)