Skip to content

Commit

Permalink
talipot-python/PythonCodeEditor: Improve selection with Shift+Home
Browse files Browse the repository at this point in the history
When selecting backwards on a line when using Shift+Home, do not select
indent patterns the first time the Home key is hit.
  • Loading branch information
anlambert committed Nov 20, 2024
1 parent 145ac03 commit b70d88e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/talipot-python/src/PythonCodeEditor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (C) 2019-2023 The Talipot developers
* Copyright (C) 2019-2024 The Talipot developers
*
* Talipot is a fork of Tulip, created by David Auber
* and the Tulip development Team from LaBRI, University of Bordeaux
Expand Down Expand Up @@ -1060,6 +1060,15 @@ void PythonCodeEditor::keyPressEvent(QKeyEvent *e) {
getCursorPosition(line, col);
setSelection(line, col, line, col - _indentPattern.length());
removeSelectedText();
} else if (e->key() == Qt::Key_Home && e->modifiers() == Qt::ShiftModifier) {
int line = 0, col = 0;
getCursorPosition(line, col);
int pos = textBeforeCursor.lastIndexOf(_indentPattern);
if (pos != -1 && (pos + _indentPattern.length()) < col) {
setSelection(line, pos + _indentPattern.length(), line, col);
} else {
QPlainTextEdit::keyPressEvent(e);
}
} else {
QPlainTextEdit::keyPressEvent(e);

Expand Down

0 comments on commit b70d88e

Please sign in to comment.