Skip to content

Commit 9f9271a

Browse files
authored
Merge pull request #427 from epasveer/420-add-a-hotkey-for-run-to-cursor
420 add a hotkey for run to cursor
2 parents c108f16 + e26b670 commit 9f9271a

9 files changed

+112
-46
lines changed

src/SeerEditorManagerWidget.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,26 @@ void SeerEditorManagerWidget::handleRunToLine (QString fullname, int lineno) {
14101410
void SeerEditorManagerWidget::handleRunToAddress (QString address) {
14111411

14121412
// rethrow
1413-
emit runToAddress (address);
1413+
if (address != "") {
1414+
emit runToAddress (address);
1415+
}
1416+
}
1417+
1418+
void SeerEditorManagerWidget::handleRunToSelectedLine () {
1419+
1420+
SeerEditorWidgetSource* sourceTab = currentEditorWidgetTab();
1421+
SeerEditorWidgetAssembly* assemblyTab = assemblyWidgetTab();
1422+
1423+
if (sourceTab) {
1424+
emit runToLine (sourceTab->sourceArea()->fullname(), sourceTab->sourceArea()->currentLine());
1425+
}
1426+
1427+
if (assemblyTab) {
1428+
QString address = assemblyTab->assemblyArea()->currentLine();
1429+
if (address != "") {
1430+
emit runToAddress (address);
1431+
}
1432+
}
14141433
}
14151434

14161435
void SeerEditorManagerWidget::handleAddVariableLoggerExpression (QString expression) {

src/SeerEditorManagerWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class SeerEditorManagerWidget : public QWidget, protected Ui::SeerEditorManagerW
9292
void handleRefreshBreakpointsStackFrames ();
9393
void handleRunToLine (QString fullname, int lineno);
9494
void handleRunToAddress (QString address);
95+
void handleRunToSelectedLine ();
9596
void handleAddVariableLoggerExpression (QString expression);
9697
void handleAddVariableTrackerExpression (QString expression);
9798
void handleRefreshVariableTrackerValues ();

src/SeerEditorWidgetAssembly.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class SeerEditorWidgetAssemblyArea : public SeerPlainTextEdit {
6363
void setAddress (const QString& address, bool force=false);
6464
const QString& address () const;
6565
bool setCurrentLine (const QString& address);
66+
const QString currentLine () const;
6667
void scrollToLine (const QString& address);
6768

6869
void clearCurrentLines ();

src/SeerEditorWidgetAssemblyAreas.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,16 @@ bool SeerEditorWidgetAssemblyArea::setCurrentLine (const QString& address) {
877877
return true;
878878
}
879879

880+
const QString SeerEditorWidgetAssemblyArea::currentLine () const {
881+
882+
// Get current lineno.
883+
int lineno = textCursor().blockNumber() + 1;
884+
885+
QString address = _lineAddressMap[lineno];
886+
887+
return address;
888+
}
889+
880890
void SeerEditorWidgetAssemblyArea::scrollToLine (const QString& address) {
881891

882892
// Just return.
@@ -1142,11 +1152,11 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo
11421152

11431153
int breakno = breakpointAddressToNumber(address);
11441154

1145-
runToAddressAction = new QAction(QString("Run to address %1").arg(address), this);
1146-
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this);
1147-
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on address %2").arg(breakno).arg(address), this);
1148-
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on address %2").arg(breakno).arg(address), this);
1149-
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on address %2").arg(breakno).arg(address), this);
1155+
runToAddressAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to address %1").arg(address), this);
1156+
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this);
1157+
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on address %2").arg(breakno).arg(address), this);
1158+
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on address %2").arg(breakno).arg(address), this);
1159+
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on address %2").arg(breakno).arg(address), this);
11501160

11511161
runToAddressAction->setEnabled(true);
11521162
createBreakpointAction->setEnabled(false);
@@ -1155,11 +1165,11 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo
11551165
disableAction->setEnabled(true);
11561166

11571167
}else{
1158-
runToAddressAction = new QAction(QString("Run to address %1").arg(address), this);
1159-
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this);
1160-
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on address %1").arg(address), this);
1161-
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on address %1").arg(address), this);
1162-
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on address %1").arg(address), this);
1168+
runToAddressAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to address %1").arg(address), this);
1169+
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this);
1170+
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on address %1").arg(address), this);
1171+
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on address %1").arg(address), this);
1172+
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on address %1").arg(address), this);
11631173

11641174
runToAddressAction->setEnabled(true);
11651175
createBreakpointAction->setEnabled(true);

src/SeerEditorWidgetSource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit {
9595
int breakpointLineToNumber (int lineno) const;
9696
bool breakpointLineEnabled (int lineno) const;
9797
void breakpointToggle ();
98+
void runToSelectedLine ();
9899

99100
void showContextMenu (QMouseEvent* event);
100101
void showContextMenu (QContextMenuEvent* event);
@@ -121,6 +122,7 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit {
121122
SeerCurrentFile readCurrentPosition ();
122123

123124
void eraseColorCurrentLine (int lineno);
125+
124126
signals:
125127
void insertBreakpoint (QString breakpoint);
126128
void insertPrintpoint (QString type, QString function, QString channel, QString parameters);

src/SeerEditorWidgetSourceAreas.cpp

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,13 @@ void SeerEditorWidgetSourceArea::breakpointToggle () {
948948
}
949949
}
950950

951+
void SeerEditorWidgetSourceArea::runToSelectedLine () {
952+
953+
// Emit the runToLine signal.
954+
emit runToLine(fullname(), currentLine());
955+
956+
}
957+
951958
void SeerEditorWidgetSourceArea::showContextMenu (QMouseEvent* event) {
952959

953960
#if QT_VERSION >= 0x060000
@@ -1005,13 +1012,13 @@ void SeerEditorWidgetSourceArea::showContextMenu (const QPoint& pos, const QPoin
10051012

10061013
int breakno = breakpointLineToNumber(lineno);
10071014

1008-
runToLineAction = new QAction(QString("Run to line %1").arg(lineno), this);
1009-
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this);
1010-
createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this);
1011-
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on line %2").arg(breakno).arg(lineno), this);
1012-
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on line %2").arg(breakno).arg(lineno), this);
1013-
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on line %2").arg(breakno).arg(lineno), this);
1014-
openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open external editor on line %1").arg(lineno), this);
1015+
runToLineAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to line %1").arg(lineno), this);
1016+
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this);
1017+
createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this);
1018+
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on line %2").arg(breakno).arg(lineno), this);
1019+
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on line %2").arg(breakno).arg(lineno), this);
1020+
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on line %2").arg(breakno).arg(lineno), this);
1021+
openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open external editor on line %1").arg(lineno), this);
10151022

10161023
runToLineAction->setEnabled(true);
10171024
createBreakpointAction->setEnabled(false);
@@ -1022,13 +1029,13 @@ void SeerEditorWidgetSourceArea::showContextMenu (const QPoint& pos, const QPoin
10221029
openExternalEditor->setEnabled(true);
10231030

10241031
}else{
1025-
runToLineAction = new QAction(QString("Run to line %1").arg(lineno), this);
1026-
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this);
1027-
createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this);
1028-
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on line %1").arg(lineno), this);
1029-
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on line %1").arg(lineno), this);
1030-
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on line %1").arg(lineno), this);
1031-
openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open file in external editor"), this);
1032+
runToLineAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to line %1").arg(lineno), this);
1033+
createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this);
1034+
createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this);
1035+
deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on line %1").arg(lineno), this);
1036+
enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on line %1").arg(lineno), this);
1037+
disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on line %1").arg(lineno), this);
1038+
openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open file in external editor"), this);
10321039

10331040
runToLineAction->setEnabled(true);
10341041
createBreakpointAction->setEnabled(true);
@@ -1734,14 +1741,15 @@ void SeerEditorWidgetSourceArea::eraseColorCurrentLine (int lineno) {
17341741
}
17351742

17361743
// Read current position in the source area: file name, line, column of cursor and first displayed line
1737-
SeerEditorWidgetSourceArea::SeerCurrentFile SeerEditorWidgetSourceArea::readCurrentPosition()
1738-
{
1744+
SeerEditorWidgetSourceArea::SeerCurrentFile SeerEditorWidgetSourceArea::readCurrentPosition() {
1745+
17391746
SeerCurrentFile info;
17401747
info.file = QFileInfo(file()).fileName(); // extract file name from full path
17411748
info.fullname = fullname();
17421749
info.cursorRow = currentLine();
17431750
info.cursorCol = currentColumn();
17441751
info.firstDisplayLine = firstDisplayLine();
1752+
17451753
return info;
17461754
}
17471755

src/SeerKeySettings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ SeerKeySettings SeerKeySettings::populate () {
8787
keySettings.add("ReverseNexti", SeerKeySetting("ReverseNexti", QKeySequence::fromString("Shift+Ctrl+F5"), "Execute the previous instruction. Step over functions."));
8888
keySettings.add("ReverseStepi", SeerKeySetting("ReverseStepi", QKeySequence::fromString("Shift+Ctrl+F6"), "Execute the previous instruction. Step into functions."));
8989
keySettings.add("ReverseFinish", SeerKeySetting("ReverseFinish", QKeySequence::fromString("Shift+F7"), "Finish the current function in reverse."));
90+
keySettings.add("RunToLine", SeerKeySetting("RunToLine", QKeySequence::fromString("F9"), "Run to the currently selected line."));
9091

9192
return keySettings;
9293
}

0 commit comments

Comments
 (0)