X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fmultilineedit.cpp;h=871f47a7607297c71881e0bb206faa8d3ffafdd6;hp=a0e0e8cc06644c089f97e2ccd7243b61ac1ebbf5;hb=ff39958dd98644e73b7b77bdd986944134f78d09;hpb=9da8a8a14a39bffe74403001978a13cc8b130138 diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index a0e0e8cc..871f47a7 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -168,6 +168,10 @@ QSize MultiLineEdit::minimumSizeHint() const { return sizeHint(); } +void MultiLineEdit::setEmacsMode(bool enable) { + _emacsMode = enable; +} + void MultiLineEdit::setSpellCheckEnabled(bool enable) { #ifdef HAVE_KDE setCheckSpellingEnabled(enable); @@ -318,6 +322,62 @@ void MultiLineEdit::keyPressEvent(QKeyEvent *event) { ; } + if(_emacsMode) { + if(event->modifiers() & Qt::ControlModifier) { + switch(event->key()) { + // move + case Qt::Key_A: + moveCursor(QTextCursor::StartOfLine); + return; + case Qt::Key_E: + moveCursor(QTextCursor::EndOfLine); + return; + case Qt::Key_F: + moveCursor(QTextCursor::Right); + return; + case Qt::Key_B: + moveCursor(QTextCursor::Left); + return; + case Qt::Key_Right: + moveCursor(QTextCursor::WordRight); + return; + case Qt::Key_Left: + moveCursor(QTextCursor::WordLeft); + return; + + // modify + case Qt::Key_Y: + paste(); + return; + case Qt::Key_K: + moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); + cut(); + return; + } + } + else if(event->modifiers() & Qt::MetaModifier) { + switch(event->key()) { + case Qt::Key_Right: + moveCursor(QTextCursor::WordRight); + return; + case Qt::Key_Left: + moveCursor(QTextCursor::WordLeft); + return; + case Qt::Key_F: + moveCursor(QTextCursor::WordRight); + return; + case Qt::Key_B: + moveCursor(QTextCursor::WordLeft); + return; + case Qt::Key_Less: + moveCursor(QTextCursor::Start); + return; + case Qt::Key_Greater: + moveCursor(QTextCursor::End); + return; + } + } + } #ifdef HAVE_KDE KTextEdit::keyPressEvent(event);