소스 검색

BUG: Fixed Console Shift+Home behavior

The console had an annoying bug: Shift+Home did not select
text up to the start of line, just jumped to the start of line
(while Shift+End already properly selected text up to the end
of line).

The problem was that Home key handling was overridden (to jump
to the end of the prompt instead of start of line) but the Shift
modifier was ignored.
Andras Lasso 10 년 전
부모
커밋
aaaa638b79
1개의 변경된 파일12개의 추가작업 그리고 1개의 파일을 삭제
  1. 12 1
      Libs/Widgets/ctkConsole.cpp

+ 12 - 1
Libs/Widgets/ctkConsole.cpp

@@ -268,8 +268,19 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e)
         break;
 
       case Qt::Key_Home:
+        // Need to override the default behavior because we want to jump to right after the prompt and
+        // not to the first character in the line (beginning of the prompt).
         e->accept();
-        text_cursor.setPosition(this->InteractivePosition);
+        if (e->modifiers() & Qt::ShiftModifier)
+          {
+          // Shift+Home - SelectStartOfLine: select from the first character to the current position
+          text_cursor.setPosition(this->InteractivePosition, QTextCursor::KeepAnchor);
+          }
+        else
+          {
+          // Home - MoveToStartOfLine: jump to first character
+          text_cursor.setPosition(this->InteractivePosition);
+          }
         this->setTextCursor(text_cursor);
         break;