Commits

Henning Schröder  committed 9125995

dedent

  • Participants
  • Parent commits 1c34118

Comments (0)

Files changed (1)

File pycode/qtintegration.py

 
 
     def keyPressEvent(self, event):
+        key = event.key()
+        modifiers = event.modifiers()
+        if key == Qt.Key_Tab:
+            tc = self._textedit.textCursor()
+            lineno = tc.blockNumber()
+            self._indenter.correct_indentation(lineno)
+            return
+        elif key == Qt.Key_Backspace:
+            tc = self._textedit.textCursor()
+            lineno = tc.blockNumber()
+            col = tc.columnNumber()
+            text = unicode(tc.block().text())[:col]
+            if text and text.strip(" \t") == "":
+                self._indenter.deindent(lineno)
+                return
+            
         self._textedit_keyPressEvent(event)
         if event.text() and self._calltip.isVisible():
             self._calltip.hide()
-        key = event.key()
-        modifiers = event.modifiers()
         if (key == Qt.Key_Space and modifiers & Qt.ControlModifier) \
            or key == Qt.Key_Period:
                self.request_completion()
                 self.request_definition()
             else:
                 lineno = self._textedit.textCursor().blockNumber()
-                self._indenter.correct_indentation(lineno)
+                self._indenter.entering_new_line(lineno)
         elif key == Qt.Key_ParenLeft:
             self.request_calltip()
 
+