aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorWiebe Cazemier <[email protected]>2014-05-02 12:08:44 +0200
committerhjk <[email protected]>2014-05-08 15:20:48 +0200
commitb63d9c6df0e6638c2b40a7351026aed6aab2b953 (patch)
tree3dcfcec0f5e00d5f9596e14890d882a506522bff /src/plugins
parent97ece795e092cf2b26f7ec84bdd5135fa70a8876 (diff)
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: hjk <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/coreplugin/editormanager/ieditor.h2
-rw-r--r--src/plugins/debugger/commonoptionspage.cpp12
-rw-r--r--src/plugins/debugger/commonoptionspage.h1
-rw-r--r--src/plugins/debugger/debuggeractions.cpp7
-rw-r--r--src/plugins/debugger/debuggeractions.h1
-rw-r--r--src/plugins/debugger/debuggerengine.cpp4
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp8
-rw-r--r--src/plugins/texteditor/basetexteditor.h4
8 files changed, 32 insertions, 7 deletions
diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h
index 199b4e48c9a..0449ee06a45 100644
--- a/src/plugins/coreplugin/editormanager/ieditor.h
+++ b/src/plugins/coreplugin/editormanager/ieditor.h
@@ -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;
diff --git a/src/plugins/debugger/commonoptionspage.cpp b/src/plugins/debugger/commonoptionspage.cpp
index 93e7586bf29..ffe72dc6aca 100644
--- a/src/plugins/debugger/commonoptionspage.cpp
+++ b/src/plugins/debugger/commonoptionspage.cpp
@@ -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);
diff --git a/src/plugins/debugger/commonoptionspage.h b/src/plugins/debugger/commonoptionspage.h
index a35bb66654a..ee6fc78a1ee 100644
--- a/src/plugins/debugger/commonoptionspage.h
+++ b/src/plugins/debugger/commonoptionspage.h
@@ -75,6 +75,7 @@ private:
QCheckBox *checkBoxBreakpointsFullPath;
QCheckBox *checkBoxRegisterForPostMortem;
QCheckBox *checkBoxWarnOnReleaseBuilds;
+ QCheckBox *checkBoxKeepEditorStationaryWhileStepping;
QLabel *labelMaximalStackDepth;
QLabel *labelMaximalStringLength;
QSpinBox *spinBoxMaximalStackDepth;
diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp
index c13f117a43e..c36bfd0169b 100644
--- a/src/plugins/debugger/debuggeractions.cpp
+++ b/src/plugins/debugger/debuggeractions.cpp
@@ -177,6 +177,13 @@ DebuggerSettings::DebuggerSettings()
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"));
item->setCheckable(true);
diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h
index 601c8e7226b..b8e7488d94a 100644
--- a/src/plugins/debugger/debuggeractions.h
+++ b/src/plugins/debugger/debuggeractions.h
@@ -93,6 +93,7 @@ enum DebuggerActionCode
SwitchModeOnExit,
BreakpointsFullPathByDefault,
RaiseOnInterrupt,
+ StationaryEditorWhileStepping,
UseDebuggingHelpers,
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index a533fdf399e..c9d6d636f2a 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -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);
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 67b808dcb69..957a6442d4d 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -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();
}
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index ac8a44ec38f..3a5382dd93f 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -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;