Skip to content

Commit

Permalink
Merge pull request #230 from epasveer/224-some-way-to-open-the-curren…
Browse files Browse the repository at this point in the history
…t-source-and-line-number-in-an-external-text-editor

224 some way to open the current source and line number in an external text editor
  • Loading branch information
epasveer authored Mar 2, 2024
2 parents fc9f969 + 599b452 commit 6cd1b66
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 40 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Added register profiles to show only interesting/relevant registers.
* Added UTF-8,16,32 support in the Memory Visualizer.
* Added an internal "dark" and "light" theme via the View->Style menu.
* Added option to open the current source file in an external editor.

## [2.3] - 2023-11-19
* In the margins of the source windows, allow CTRL+DoubleClick to do a quick RunToLine or RunToAddress.
Expand Down
10 changes: 10 additions & 0 deletions src/SeerConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ bool SeerConfigDialog::editorHighlighterEnabled () const {
return _editorConfigPage->highlighterEnabled();
}

void SeerConfigDialog::setExternalEditorCommand (const QString& externalEditorCommand) {

_editorConfigPage->setExternalEditorCommand(externalEditorCommand);
}

QString SeerConfigDialog::externalEditorCommand () const {

return _editorConfigPage->externalEditorCommand();
}

void SeerConfigDialog::setSourceAlternateDirectories (const QStringList& alternateDirectories) {

_sourceConfigPage->setAlternateDirectories(alternateDirectories);
Expand Down
3 changes: 3 additions & 0 deletions src/SeerConfigDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class SeerConfigDialog : public QDialog, protected Ui::SeerConfigDialogForm {
void setEditorHighlighterEnabled (bool flag);
bool editorHighlighterEnabled () const;

void setExternalEditorCommand (const QString& externalEditorCommand);
QString externalEditorCommand () const;

// Source settings.
void setSourceAlternateDirectories (const QStringList& alternateDirectories);
QStringList sourceAlternateDirectories () const;
Expand Down
11 changes: 11 additions & 0 deletions src/SeerEditorConfigPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,23 @@ bool SeerEditorConfigPage::highlighterEnabled () const {
return editorWidget->sourceArea()->highlighterEnabled();
}

void SeerEditorConfigPage::setExternalEditorCommand (const QString& externalEditorCommand) {

externalEditorCommandLineEdit->setText(externalEditorCommand);
}

QString SeerEditorConfigPage::externalEditorCommand () const {

return externalEditorCommandLineEdit->text();
}

void SeerEditorConfigPage::reset () {

setEditorFont(QFont("monospace", 10));
setEditorTabSize(4);
setHighlighterSettings(SeerHighlighterSettings::populateForCPP(""));
setHighlighterEnabled(true);
setExternalEditorCommand("");
}

void SeerEditorConfigPage::handleFontSizeChanged (const QString& text) {
Expand Down
3 changes: 3 additions & 0 deletions src/SeerEditorConfigPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SeerEditorConfigPage : public QWidget, public Ui::SeerEditorConfigPage {
void setHighlighterEnabled (bool flag);
bool highlighterEnabled () const;

void setExternalEditorCommand (const QString& externalEditorCommand);
QString externalEditorCommand () const;

void reset ();

protected slots:
Expand Down
80 changes: 56 additions & 24 deletions src/SeerEditorConfigPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<x>0</x>
<y>0</y>
<width>728</width>
<height>719</height>
<height>876</height>
</rect>
</property>
<property name="windowTitle">
<string>SeerEditorConfigPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_1">
<item>
<widget class="QFontComboBox" name="fontNameComboBox">
Expand Down Expand Up @@ -45,7 +45,7 @@
</item>
</layout>
</item>
<item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="highlighterEnabledCheckBox">
Expand All @@ -72,7 +72,7 @@
</item>
</layout>
</item>
<item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="themeLabel">
Expand Down Expand Up @@ -146,7 +146,7 @@
</item>
</layout>
</item>
<item>
<item row="3" column="0">
<widget class="SeerEditorWidgetSource" name="editorWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
Expand All @@ -156,7 +156,7 @@
</property>
</widget>
</item>
<item>
<item row="4" column="0">
<widget class="QTableWidget" name="highlighterTableWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
Expand Down Expand Up @@ -207,38 +207,70 @@
</column>
</widget>
</item>
<item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="externalEditorCommandLabel">
<property name="text">
<string>External Editor Command</string>
</property>
</widget>
</item>
<item>
<widget class="QHistoryLineEdit" name="externalEditorCommandLineEdit">
<property name="toolTip">
<string>Command to launch external editor.</string>
</property>
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>myeditor --line %{line} &quot;%{file}&quot;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QTextBrowser" name="helpTextBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>25</verstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Specify font and syntax highlighting colors for the code editor.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These formats apply only when highlighting is enabled and if the file is C or C++.&lt;/p&gt;
&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Class&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Comment&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Multiline Comment&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Function&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Keyword&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Quotation&lt;/li&gt;&lt;/ul&gt;
&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Class&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Comment&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Multiline Comment&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Function&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Keyword&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Quotation&lt;/li&gt;&lt;/ul&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;These formats apply for any type of file. &lt;/p&gt;
&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Margin&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Text&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Assembly Text&lt;/li&gt;
&lt;li style=&quot;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Current Line&lt;/li&gt;&lt;/ul&gt;
&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Margin&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Text&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Assembly Text&lt;/li&gt;
&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Current Line&lt;/li&gt;&lt;/ul&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Syntax highlighting can be enabled or disabled. The list of suffixes for C/C++ source files can be changed. Example:&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; &amp;quot;.h|.cpp|.c&amp;quot;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&amp;quot;.h|.cpp|.c&amp;quot;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The tab size, in spaces, can be set to properly display source files that contain tab characters.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;You may need to close and reopen the source files for changes to take effect.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;You can specify a command to launch an external editor. While in a source window, you can use the RMB menu to launch the external editor on the current file. However, these changes are not recognized by Seer. When specifying the command, you have these two variables. One for the name of the source file, and one for the line number to tell the editor to go to. Here are a few examples:&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'monospace'; &quot;&gt;geany &amp;quot;%{file}&amp;quot;:%{line}&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; &quot;&gt;kate --line %{line} &amp;quot;%{file}&amp;quot;&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; &quot;&gt;gedit &amp;quot;%{file}&amp;quot; +%{line}&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-family:'monospace'; &quot;&gt;konsole -e vim &amp;quot;%{file}&amp;quot; +%{line}&lt;/span&gt;&lt;span style=&quot; font-family:'monospace';&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;You may need to close and reopen the source files for changes to take effect.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down
54 changes: 39 additions & 15 deletions src/SeerEditorManagerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
SeerEditorManagerWidget::SeerEditorManagerWidget (QWidget* parent) : QWidget(parent) {

// Initialize private data
_editorFont = QFont("monospace", 10); // Default font.
_editorHighlighterSettings = SeerHighlighterSettings::populateForCPP(""); // Default syntax highlighting.
_editorHighlighterEnabled = true;
_editorKeySettings = SeerKeySettings::populate(); // Default key settings.
_editorTabSize = 4;
_assemblyWidget = 0;
_keepAssemblyTabOnTop = true;
_showAddressColumn = true;
_showOffsetColumn = false;
_showOpcodeColumn = false;
_showSourceLines = false;
_notifyAssemblyTabShown = true;
_editorFont = QFont("monospace", 10); // Default font.
_editorHighlighterSettings = SeerHighlighterSettings::populateForCPP(""); // Default syntax highlighting.
_editorHighlighterEnabled = true;
_editorKeySettings = SeerKeySettings::populate(); // Default key settings.
_editorTabSize = 4;
_editorExternalEditorCommand = "";
_assemblyWidget = 0;
_keepAssemblyTabOnTop = true;
_showAddressColumn = true;
_showOffsetColumn = false;
_showOpcodeColumn = false;
_showSourceLines = false;
_notifyAssemblyTabShown = true;

// Setup UI
setupUi(this);
Expand Down Expand Up @@ -255,7 +256,7 @@ void SeerEditorManagerWidget::setEditorFont (const QFont& font) {

_editorFont = font;

// Set the code widgets.
// Update current editors.
SeerEditorManagerEntries::iterator b = beginEntry();
SeerEditorManagerEntries::iterator e = endEntry();

Expand All @@ -281,7 +282,7 @@ void SeerEditorManagerWidget::setEditorHighlighterSettings (const SeerHighlighte

_editorHighlighterSettings = settings;

// Set the code widgets.
// Update current editors.
SeerEditorManagerEntries::iterator b = beginEntry();
SeerEditorManagerEntries::iterator e = endEntry();

Expand All @@ -307,7 +308,7 @@ void SeerEditorManagerWidget::setEditorHighlighterEnabled (bool flag) {

_editorHighlighterEnabled = flag;

// Set the code widgets.
// Update current editors.
SeerEditorManagerEntries::iterator b = beginEntry();
SeerEditorManagerEntries::iterator e = endEntry();

Expand All @@ -333,6 +334,7 @@ void SeerEditorManagerWidget::setEditorAlternateDirectories (const QStringList a

_editorAlternateDirectories = alternateDirectories;

// Update current editors.
SeerEditorManagerEntries::iterator b = beginEntry();
SeerEditorManagerEntries::iterator e = endEntry();

Expand Down Expand Up @@ -361,6 +363,7 @@ void SeerEditorManagerWidget::setEditorKeySettings (const SeerKeySettings& setti

_editorKeySettings = settings;

// Update current editors.
SeerEditorManagerEntries::iterator b = beginEntry();
SeerEditorManagerEntries::iterator e = endEntry();

Expand Down Expand Up @@ -392,6 +395,25 @@ int SeerEditorManagerWidget::editorTabSize () const {
return _editorTabSize;
}

void SeerEditorManagerWidget::setEditorExternalEditorCommand (const QString& externalEditorCommand) {

_editorExternalEditorCommand = externalEditorCommand;

// Update current editors.
SeerEditorManagerEntries::iterator b = beginEntry();
SeerEditorManagerEntries::iterator e = endEntry();

while (b != e) {
b->widget->sourceArea()->setExternalEditorCommand(_editorExternalEditorCommand);
b++;
}
}

const QString& SeerEditorManagerWidget::editorExternalEditorCommand () const {

return _editorExternalEditorCommand;
}

void SeerEditorManagerWidget::handleText (const QString& text) {

if (text.startsWith("*stopped")) {
Expand Down Expand Up @@ -789,6 +811,7 @@ SeerEditorWidgetSource* SeerEditorManagerWidget::createEditorWidgetTab (const QS
SeerEditorWidgetSource* editorWidget = new SeerEditorWidgetSource(this);
editorWidget->sourceArea()->setEditorFont(editorFont());
editorWidget->sourceArea()->setEditorTabSize(editorTabSize());
editorWidget->sourceArea()->setExternalEditorCommand(editorExternalEditorCommand());
editorWidget->sourceArea()->setHighlighterSettings(editorHighlighterSettings());
editorWidget->sourceArea()->setHighlighterEnabled(editorHighlighterEnabled());
editorWidget->sourceArea()->setAlternateDirectories(editorAlternateDirectories());
Expand Down Expand Up @@ -848,6 +871,7 @@ SeerEditorWidgetSource* SeerEditorManagerWidget::createEditorWidgetTab (const QS
SeerEditorWidgetSource* editorWidget = new SeerEditorWidgetSource(this);
editorWidget->sourceArea()->setEditorFont(editorFont());
editorWidget->sourceArea()->setEditorTabSize(editorTabSize());
editorWidget->sourceArea()->setExternalEditorCommand(editorExternalEditorCommand());
editorWidget->sourceArea()->setHighlighterSettings(editorHighlighterSettings());
editorWidget->sourceArea()->setHighlighterEnabled(editorHighlighterEnabled());
editorWidget->sourceArea()->setAlternateDirectories(editorAlternateDirectories());
Expand Down
Loading

0 comments on commit 6cd1b66

Please sign in to comment.