Revert "Reset the input prior to processing it in order to prevent issues with per...
[quassel.git] / src / uisupport / multilineedit.cpp
index 114c613..82f25de 100644 (file)
@@ -40,6 +40,7 @@ MultiLineEdit::MultiLineEdit(QWidget *parent)
     _maxHeight(5),
     _scrollBarsEnabled(true),
     _pasteProtectionEnabled(true),
+    _emacsMode(false),
     _lastDocumentHeight(-1)
 {
 #if QT_VERSION >= 0x040500
@@ -347,6 +348,9 @@ void MultiLineEdit::keyPressEvent(QKeyEvent *event) {
         moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
         cut();
         return;
+
+      default:
+        break;
       }
     }
     else if(event->modifiers() & Qt::MetaModifier ||
@@ -394,6 +398,29 @@ void MultiLineEdit::keyPressEvent(QKeyEvent *event) {
         textCursor().insertText(text.left(1).toUpper() + text.mid(1).toLower());
         return;
       }
+
+      case Qt::Key_T: { // transpose words
+        moveCursor(QTextCursor::StartOfWord);
+        moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+        QString const word1 = textCursor().selectedText();
+        textCursor().clearSelection();
+        moveCursor(QTextCursor::WordRight);
+        moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+        QString const word2 = textCursor().selectedText();
+        if(!word2.isEmpty() && !word1.isEmpty()) {
+          textCursor().insertText(word1);
+          moveCursor(QTextCursor::WordLeft);
+          moveCursor(QTextCursor::WordLeft);
+          moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
+          textCursor().insertText(word2);
+          moveCursor(QTextCursor::WordRight);
+          moveCursor(QTextCursor::EndOfWord);
+        }
+        return;
+      }
+
+      default:
+        break;
       }
     }
   }