[QGIS Commit] r12858 - trunk/qgis/python

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Feb 1 14:10:17 EST 2010


Author: wonder
Date: 2010-02-01 14:10:15 -0500 (Mon, 01 Feb 2010)
New Revision: 12858

Modified:
   trunk/qgis/python/console.py
Log:
Fixed few problems in console:
- pressing enter if the cursor was not at the end
- ctrl+shift to select words didn't work


Modified: trunk/qgis/python/console.py
===================================================================
--- trunk/qgis/python/console.py	2010-02-01 14:49:59 UTC (rev 12857)
+++ trunk/qgis/python/console.py	2010-02-01 19:10:15 UTC (rev 12858)
@@ -179,7 +179,7 @@
         self.cursor = self.textCursor()
         # if the cursor isn't in the edition zone, don't do anything except Ctrl+C
         if not self.isCursorInEditionZone():
-            if e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier:
+            if e.modifiers() & Qt.ControlModifier or e.modifiers() & Qt.MetaModifier:
                 if e.key() == Qt.Key_C or e.key() == Qt.Key_A:
                     QTextEdit.keyPressEvent(self, e)
             else:
@@ -201,38 +201,22 @@
                 QTextEdit.keyPressEvent(self, e)
             # if the left key is pressed, move left until we get to the prompt
             elif e.key() == Qt.Key_Left and self.cursor.position() > self.document().lastBlock().position() + self.currentPromptLength:
-                if e.modifiers() == Qt.ShiftModifier:
-                    anchor = QTextCursor.KeepAnchor
-                else:
-                    anchor = QTextCursor.MoveAnchor
-                if (e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier):
-                    self.cursor.movePosition(QTextCursor.WordLeft, anchor)
-                else:
-                    self.cursor.movePosition(QTextCursor.Left, anchor)
+                anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor
+                move = QTextCursor.WordLeft if e.modifiers() & Qt.ControlModifier or e.modifiers() & Qt.MetaModifier else QTextCursor.Left
+                self.cursor.movePosition(move, anchor)
             # use normal operation for right key
             elif e.key() == Qt.Key_Right:
-                if e.modifiers() == Qt.ShiftModifier:
-                    anchor = QTextCursor.KeepAnchor
-                else:
-                    anchor = QTextCursor.MoveAnchor
-                if (e.modifiers() == Qt.ControlModifier or e.modifiers() == Qt.MetaModifier):
-                    self.cursor.movePosition(QTextCursor.WordRight, anchor)
-                else:
-                    self.cursor.movePosition(QTextCursor.Right, anchor)
+                anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor
+                move = QTextCursor.WordRight if e.modifiers() & Qt.ControlModifier or e.modifiers() & Qt.MetaModifier else QTextCursor.Right
+                self.cursor.movePosition(move, anchor)
             # if home is pressed, move cursor to right of prompt
             elif e.key() == Qt.Key_Home:
-                if e.modifiers() == Qt.ShiftModifier:
-                    anchor = QTextCursor.KeepAnchor
-                else:
-                    anchor = QTextCursor.MoveAnchor
+                anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor
                 self.cursor.movePosition(QTextCursor.StartOfBlock, anchor, 1)
                 self.cursor.movePosition(QTextCursor.Right, anchor, self.currentPromptLength)
             # use normal operation for end key
             elif e.key() == Qt.Key_End:
-                if e.modifiers() == Qt.ShiftModifier:
-                    anchor = QTextCursor.KeepAnchor
-                else:
-                    anchor = QTextCursor.MoveAnchor
+                anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor
                 self.cursor.movePosition(QTextCursor.EndOfBlock, anchor, 1)
             # use normal operation for all remaining keys
             else:
@@ -253,6 +237,7 @@
 
   def entered(self):
     self.cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor)
+    self.setTextCursor(self.cursor)
     self.runCommand( unicode(self.currentCommand()) )
 
   def runCommand(self, cmd):



More information about the QGIS-commit mailing list