ui: Iterate code references within the same line when holding Shift (#936)

This commit is contained in:
Eberhard Gräther
2020-03-05 15:41:17 +01:00
committed by GitHub
parent e8f258ba1d
commit 38925292b7
11 changed files with 93 additions and 60 deletions
+22 -34
View File
@@ -703,60 +703,48 @@ void QtCodeNavigator::keyPressEvent(QKeyEvent* event)
currentFilePath = currentFocus.area->getFilePath();
}
auto moveFocus = [=](CodeFocusHandler::Direction direction) {
if (!alt && !ctrl)
{
if (shift)
{
MessageToNextCodeReference(
currentFilePath, currentFocus.lineNumber, currentFocus.columnNumber,
direction == CodeFocusHandler::Direction::DOWN || direction == CodeFocusHandler::Direction::RIGHT
).dispatch();
}
else
{
m_current->moveFocus(currentFocus, direction);
scrollToFocus();
}
}
};
switch (event->key())
{
case Qt::Key_Up:
case Qt::Key_K:
case Qt::Key_W:
if (!alt && !ctrl)
{
if (shift)
{
MessageToNextCodeReference(currentFilePath, currentFocus.lineNumber, false).dispatch();
}
else
{
m_current->moveFocus(currentFocus, CodeFocusHandler::Direction::UP);
scrollToFocus();
}
}
moveFocus(CodeFocusHandler::Direction::UP);
break;
case Qt::Key_Down:
case Qt::Key_J:
case Qt::Key_S:
if (!alt && !ctrl)
{
if (shift)
{
MessageToNextCodeReference(currentFilePath, currentFocus.lineNumber, true).dispatch();
}
else
{
m_current->moveFocus(currentFocus, CodeFocusHandler::Direction::DOWN);
scrollToFocus();
}
}
moveFocus(CodeFocusHandler::Direction::DOWN);
break;
case Qt::Key_Left:
case Qt::Key_H:
case Qt::Key_A:
if (!alt && !ctrl)
{
m_current->moveFocus(currentFocus, CodeFocusHandler::Direction::LEFT);
scrollToFocus();
}
moveFocus(CodeFocusHandler::Direction::LEFT);
break;
case Qt::Key_Right:
case Qt::Key_L:
case Qt::Key_D:
if (!alt && !ctrl)
{
m_current->moveFocus(currentFocus, CodeFocusHandler::Direction::RIGHT);
scrollToFocus();
}
moveFocus(CodeFocusHandler::Direction::RIGHT);
break;
case Qt::Key_E: