コード例 #1
0
ファイル: view.py プロジェクト: arnaldorusso/frescobaldi
 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)):
             indent.auto_indent_block(cursor.block())
             # fix subsequent vertical moves
             cursor.setPosition(cursor.position())
             self.setTextCursor(cursor)
コード例 #2
0
ファイル: view.py プロジェクト: ryanakca/frescobaldi
    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)):
                indent.auto_indent_block(cursor.block())
                # fix subsequent vertical moves
                cursor.setPosition(cursor.position())
                self.setTextCursor(cursor)
コード例 #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)