X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fmultilineedit.cpp;h=82f25de3147c4aac960bcb7f45301610bae9255b;hp=b856954f9c352a17db1c769f302401920b05d859;hb=6813a6cb41260d7c6d30d04761ac6f13d28bab06;hpb=2c98de2f80025d91d287299f56b9a22f8e670559 diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index b856954f..82f25de3 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -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 || @@ -371,6 +375,52 @@ void MultiLineEdit::keyPressEvent(QKeyEvent *event) { case Qt::Key_Greater: moveCursor(QTextCursor::End); return; + + // modify + case Qt::Key_D: + moveCursor(QTextCursor::WordRight, QTextCursor::KeepAnchor); + cut(); + return; + + case Qt::Key_U: // uppercase word + moveCursor(QTextCursor::WordRight, QTextCursor::KeepAnchor); + textCursor().insertText(textCursor().selectedText().toUpper()); + return; + + case Qt::Key_L: // lowercase word + moveCursor(QTextCursor::WordRight, QTextCursor::KeepAnchor); + textCursor().insertText(textCursor().selectedText().toLower()); + return; + + case Qt::Key_C: { // capitalize word + moveCursor(QTextCursor::WordRight, QTextCursor::KeepAnchor); + QString const text = textCursor().selectedText(); + 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; } } }