Permalink
Browse files

Merge pull request #2721 from sisao/pythonChartCursorMoveHome

Move cursor in PythonChart to correct start point
  • Loading branch information...
amtriathlon committed Jan 12, 2018
2 parents 6ee8b22 + e01b110 commit 410c8505564ff3b861115b355547a446db3d82f6
Showing with 11 additions and 2 deletions.
  1. +10 −2 src/Charts/PythonChart.cpp
  2. +1 −0 src/Charts/PythonChart.h
View
@@ -125,7 +125,15 @@ void PythonConsole::keyPressEvent(QKeyEvent *e)
// you can only delete or move left from past first character
case Qt::Key_Left:
case Qt::Key_Backspace:
if (textCursor().position() - textCursor().block().position() > 4) QTextEdit::keyPressEvent(e);
if (textCursor().positionInBlock() > promptStartIndex) QTextEdit::keyPressEvent(e);
break;
case Qt::Key_Home:
{
QTextCursor moveHome = textCursor();
moveHome.setPosition(textCursor().block().position() + promptStartIndex, QTextCursor::MoveAnchor);
setTextCursor(moveHome);
}
break;
case Qt::Key_Escape: // R typically uses ESC to cancel
@@ -166,7 +174,7 @@ void PythonConsole::keyPressEvent(QKeyEvent *e)
setTextCursor(move);
QString line = currentLine();
if (line.length() > 4) line = line.mid(4, line.length()-4);
if (line.length() > promptStartIndex) line = line.mid(promptStartIndex, line.length() - promptStartIndex);
else line = "";
putData("\n");
View
@@ -77,6 +77,7 @@ public slots:
Context *context;
bool localEchoEnabled;
PythonChart *parent;
int promptStartIndex = 4;
};
// the chart

0 comments on commit 410c850

Please sign in to comment.