forked from qt-creator/qt-creator
Use proper standard keysequences for MoveTo/Select
StartOfLine/StartOfBlock. Eventually we want to switch all that to actions, so we can have unix-style input also on the mac and vice versa by setting different keybinding schemes.
This commit is contained in:
@@ -898,6 +898,27 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
|
||||
e->accept();
|
||||
setTextCursor(cursor);
|
||||
return;
|
||||
} else if (!ro
|
||||
&& (e == QKeySequence::MoveToStartOfBlock
|
||||
|| e == QKeySequence::SelectStartOfBlock)){
|
||||
if ((e->modifiers() & (Qt::AltModifier | Qt::ShiftModifier)) == (Qt::AltModifier | Qt::ShiftModifier))
|
||||
d->m_lastEventWasBlockSelectionEvent = true;
|
||||
handleHomeKey(e == QKeySequence::SelectStartOfBlock);
|
||||
e->accept();
|
||||
return;
|
||||
} else if (!ro
|
||||
&& (e == QKeySequence::MoveToStartOfLine
|
||||
|| e == QKeySequence::SelectStartOfLine)){
|
||||
if ((e->modifiers() & (Qt::AltModifier | Qt::ShiftModifier)) == (Qt::AltModifier | Qt::ShiftModifier))
|
||||
d->m_lastEventWasBlockSelectionEvent = true;
|
||||
QTextCursor cursor = textCursor();
|
||||
if (QTextLayout *layout = cursor.block().layout()) {
|
||||
if (layout->lineForTextPosition(cursor.position() - cursor.block().position()).lineNumber() == 0) {
|
||||
handleHomeKey(e == QKeySequence::SelectStartOfLine);
|
||||
e->accept();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else switch (e->key()) {
|
||||
|
||||
|
||||
@@ -948,15 +969,6 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Home:
|
||||
if (!(e == QKeySequence::MoveToStartOfDocument) && !(e == QKeySequence::SelectStartOfDocument)) {
|
||||
if ((e->modifiers() & (Qt::AltModifier | Qt::ShiftModifier)) == (Qt::AltModifier | Qt::ShiftModifier))
|
||||
d->m_lastEventWasBlockSelectionEvent = true;
|
||||
handleHomeKey(e->modifiers() & Qt::ShiftModifier);
|
||||
e->accept();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
case Qt::Key_Down:
|
||||
if (e->modifiers() & Qt::ControlModifier) {
|
||||
|
||||
Reference in New Issue
Block a user