Commit b63d9c6d authored by Wiebe Cazemier's avatar Wiebe Cazemier Committed by hjk

Adds option to make editor not scroll on debugging

Added an option to change the behavior of the debuggercore so that
the current editor isn't always centered on the current line, to stop
unnecessary jumping of the code.

Change-Id: I9406df518bb1b977e39a0265ee7fd6fae2069ed9
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 97ece795
......@@ -58,7 +58,7 @@ public:
virtual int currentLine() const { return 0; }
virtual int currentColumn() const { return 0; }
virtual void gotoLine(int line, int column = 0) { Q_UNUSED(line) Q_UNUSED(column) }
virtual void gotoLine(int line, int column = 0, bool centerLine = true) { Q_UNUSED(line) Q_UNUSED(column) Q_UNUSED(centerLine) }
virtual QWidget *toolBar() = 0;
......
......@@ -98,6 +98,13 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
checkBoxWarnOnReleaseBuilds->setToolTip(tr("Shows a warning when starting the debugger "
"on a binary with insufficient debug information."));
checkBoxKeepEditorStationaryWhileStepping = new QCheckBox(behaviorBox);
checkBoxKeepEditorStationaryWhileStepping->setText(tr("Keep editor stationary when stepping"));
checkBoxKeepEditorStationaryWhileStepping->setToolTip(tr("Scrolls the editor only when it is necessary "
"to keep the current line in view, "
"instead of keeping the next statement centered at "
"all times."));
labelMaximalStackDepth = new QLabel(tr("Maximum stack depth:"), behaviorBox);
spinBoxMaximalStackDepth = new QSpinBox(behaviorBox);
......@@ -139,7 +146,8 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
gridLayout->addWidget(checkBoxListSourceFiles, 1, 1, 1, 1);
gridLayout->addWidget(checkBoxSwitchModeOnExit, 2, 1, 1, 1);
gridLayout->addWidget(checkBoxShowQmlObjectTree, 3, 1, 1, 1);
gridLayout->addWidget(checkBoxRegisterForPostMortem, 4, 1, 1, 1);
gridLayout->addWidget(checkBoxKeepEditorStationaryWhileStepping, 4, 1, 1, 1);
gridLayout->addWidget(checkBoxRegisterForPostMortem, 5, 1, 1, 1);
gridLayout->addLayout(horizontalLayout2, 6, 1, 1, 2);
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
......@@ -168,6 +176,8 @@ CommonOptionsPageWidget::CommonOptionsPageWidget
checkBoxShowQmlObjectTree);
m_group->insert(dc->action(WarnOnReleaseBuilds),
checkBoxWarnOnReleaseBuilds);
m_group->insert(dc->action(StationaryEditorWhileStepping),
checkBoxKeepEditorStationaryWhileStepping);
m_group->insert(dc->action(FontSizeFollowsEditor),
checkBoxFontSizeFollowsEditor);
m_group->insert(dc->action(AutoDerefPointers), 0);
......
......@@ -75,6 +75,7 @@ private:
QCheckBox *checkBoxBreakpointsFullPath;
QCheckBox *checkBoxRegisterForPostMortem;
QCheckBox *checkBoxWarnOnReleaseBuilds;
QCheckBox *checkBoxKeepEditorStationaryWhileStepping;
QLabel *labelMaximalStackDepth;
QLabel *labelMaximalStringLength;
QSpinBox *spinBoxMaximalStackDepth;
......
......@@ -176,6 +176,13 @@ DebuggerSettings::DebuggerSettings()
item->setDefaultValue(false);
insertItem(UseAlternatingRowColors, item);
item = new SavedAction(this);
item->setText(tr("Keep Editor Stationary When Stepping"));
item->setSettingsKey(debugModeGroup, QLatin1String("StationaryEditorWhileStepping"));
item->setCheckable(true);
item->setDefaultValue(false);
insertItem(StationaryEditorWhileStepping, item);
item = new SavedAction(this);
item->setText(tr("Debugger Font Size Follows Main Editor"));
item->setSettingsKey(debugModeGroup, QLatin1String("FontSizeFollowsEditor"));
......
......@@ -93,6 +93,7 @@ enum DebuggerActionCode
SwitchModeOnExit,
BreakpointsFullPathByDefault,
RaiseOnInterrupt,
StationaryEditorWhileStepping,
UseDebuggingHelpers,
......
......@@ -540,7 +540,9 @@ void DebuggerEngine::gotoLocation(const Location &loc)
IEditor *editor = EditorManager::openEditor(file, Id(),
EditorManager::IgnoreNavigationHistory, &newEditor);
QTC_ASSERT(editor, return); // Unreadable file?
editor->gotoLine(line, 0);
editor->gotoLine(line, 0, !debuggerCore()->boolSetting(StationaryEditorWhileStepping));
if (newEditor)
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
......
......@@ -1963,7 +1963,7 @@ void BaseTextEditorWidget::setTextCursor(const QTextCursor &cursor)
slotSelectionChanged();
}
void BaseTextEditorWidget::gotoLine(int line, int column)
void BaseTextEditorWidget::gotoLine(int line, int column, bool centerLine)
{
d->m_lastCursorChangeWasInteresting = false; // avoid adding the previous position to history
const int blockNumber = line - 1;
......@@ -1980,7 +1980,11 @@ void BaseTextEditorWidget::gotoLine(int line, int column)
cursor.setPosition(pos);
}
setTextCursor(cursor);
centerCursor();
if (centerLine)
centerCursor();
else
ensureCursorVisible();
}
saveCurrentCursorPositionForNavigation();
}
......
......@@ -141,7 +141,7 @@ public:
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
void gotoLine(int line, int column = 0);
void gotoLine(int line, int column = 0, bool centerLine = true);
int position(ITextEditor::PositionOperation posOp = ITextEditor::Current,
int at = -1) const;
void convertPosition(int pos, int *line, int *column) const;
......@@ -584,7 +584,7 @@ public:
// ITextEditor
int currentLine() const;
int currentColumn() const;
void gotoLine(int line, int column = 0) { m_editorWidget->gotoLine(line, column); }
void gotoLine(int line, int column = 0, bool centerLine = true) { m_editorWidget->gotoLine(line, column, centerLine); }
int columnCount() const;
int rowCount() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment