diff --git a/src/SeerConfigDialog.cpp b/src/SeerConfigDialog.cpp index a5a82d0..23f3568 100644 --- a/src/SeerConfigDialog.cpp +++ b/src/SeerConfigDialog.cpp @@ -314,6 +314,16 @@ QString SeerConfigDialog::externalEditorCommand () const { return _editorConfigPage->externalEditorCommand(); } +void SeerConfigDialog::setEditorAutoSourceReload (bool flag) { + + _editorConfigPage->setAutoSourceReload(flag); +} + +bool SeerConfigDialog::editorAutoSourceReload () const { + + return _editorConfigPage->autoSourceReload(); +} + void SeerConfigDialog::setSourceAlternateDirectories (const QStringList& alternateDirectories) { _sourceConfigPage->setAlternateDirectories(alternateDirectories); diff --git a/src/SeerConfigDialog.h b/src/SeerConfigDialog.h index 2fa9e1f..d1042e4 100644 --- a/src/SeerConfigDialog.h +++ b/src/SeerConfigDialog.h @@ -91,6 +91,9 @@ class SeerConfigDialog : public QDialog, protected Ui::SeerConfigDialogForm { void setExternalEditorCommand (const QString& externalEditorCommand); QString externalEditorCommand () const; + void setEditorAutoSourceReload (bool flag); + bool editorAutoSourceReload () const; + // Source settings. void setSourceAlternateDirectories (const QStringList& alternateDirectories); QStringList sourceAlternateDirectories () const; diff --git a/src/SeerEditorConfigPage.cpp b/src/SeerEditorConfigPage.cpp index fb251e6..0327ece 100644 --- a/src/SeerEditorConfigPage.cpp +++ b/src/SeerEditorConfigPage.cpp @@ -179,6 +179,16 @@ QString SeerEditorConfigPage::externalEditorCommand () const { return externalEditorCommandLineEdit->text(); } +void SeerEditorConfigPage::setAutoSourceReload (bool flag) { + + autoReloadSourceFileCheckBox->setChecked(flag); +} + +bool SeerEditorConfigPage::autoSourceReload () const { + + return autoReloadSourceFileCheckBox->isChecked(); +} + void SeerEditorConfigPage::reset () { setEditorFont(QFont("monospace", 10)); @@ -186,6 +196,7 @@ void SeerEditorConfigPage::reset () { setHighlighterSettings(SeerHighlighterSettings::populate("")); setHighlighterEnabled(true); setExternalEditorCommand(""); + setAutoSourceReload(false); } void SeerEditorConfigPage::handleFontSizeChanged (const QString& text) { diff --git a/src/SeerEditorConfigPage.h b/src/SeerEditorConfigPage.h index e772e04..2727bac 100644 --- a/src/SeerEditorConfigPage.h +++ b/src/SeerEditorConfigPage.h @@ -33,6 +33,9 @@ class SeerEditorConfigPage : public QWidget, public Ui::SeerEditorConfigPage { void setExternalEditorCommand (const QString& externalEditorCommand); QString externalEditorCommand () const; + void setAutoSourceReload (bool flag); + bool autoSourceReload () const; + void reset (); protected slots: diff --git a/src/SeerEditorConfigPage.ui b/src/SeerEditorConfigPage.ui index f50164e..8e51b1c 100644 --- a/src/SeerEditorConfigPage.ui +++ b/src/SeerEditorConfigPage.ui @@ -262,15 +262,22 @@ - - + + + + + Auto Source Reload + + + + External Editor Command - + Command to launch external editor. @@ -286,6 +293,16 @@ + + + + Automatically reload source files if they are externally modified. + + + + + + @@ -323,8 +340,10 @@ li.checked::marker { content: "\2612"; } <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&quot;.h|.cpp|.c&quot;</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The tab size, in spaces, can be set to properly display source files that contain tab characters.</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">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:</p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace';">geany &quot;%{file}&quot;:%{line}<br />kate --line %{line} &quot;%{file}&quot;<br />gedit &quot;%{file}&quot; +%{line}<br />konsole -e vim &quot;%{file}&quot; +%{line}<br /><br /></span>You may need to close and reopen the source files for changes to take effect.</p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'monospace';">geany &quot;%{file}&quot;:%{line}<br />kate --line %{line} &quot;%{file}&quot;<br />gedit &quot;%{file}&quot; +%{line}<br />konsole -e vim &quot;%{file}&quot; +%{line}<br /><br /></span>Seer detects if the underlining source file is modified externally. Seer can automatically reload the file or prompt you to reload it.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You may need to close and reopen the source files for changes to take effect.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Seer detects if the underlining source file is modified. Seer can automatically reload the file or prompt you to reload it.</p> +<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> diff --git a/src/SeerEditorManagerWidget.cpp b/src/SeerEditorManagerWidget.cpp index 03457ab..710d1f3 100644 --- a/src/SeerEditorManagerWidget.cpp +++ b/src/SeerEditorManagerWidget.cpp @@ -31,6 +31,7 @@ SeerEditorManagerWidget::SeerEditorManagerWidget (QWidget* parent) : QWidget(par _editorKeySettings = SeerKeySettings::populate(); // Default key settings. _editorTabSize = 4; _editorExternalEditorCommand = ""; + _editorAutoSourceReload = false; _assemblyWidget = 0; _showAssemblyTabOnStartupMode = "never"; _keepAssemblyTabOnTop = true; @@ -461,6 +462,25 @@ const QString& SeerEditorManagerWidget::editorExternalEditorCommand () const { return _editorExternalEditorCommand; } +void SeerEditorManagerWidget::setEditorAutoSourceReload (bool flag) { + + _editorAutoSourceReload = flag; + + // Update current editors. + SeerEditorManagerEntries::iterator b = beginEntry(); + SeerEditorManagerEntries::iterator e = endEntry(); + + while (b != e) { + b->widget->sourceArea()->setAutoSourceReload(_editorAutoSourceReload); + b++; + } +} + +bool SeerEditorManagerWidget::editorAutoSourceReload () const { + + return _editorAutoSourceReload; +} + void SeerEditorManagerWidget::handleText (const QString& text) { // Update the current line. @@ -982,6 +1002,7 @@ SeerEditorWidgetSource* SeerEditorManagerWidget::editorWidgetTab (const QString& return 0; } + // Return the editor widget. return i->widget; } @@ -1007,6 +1028,7 @@ SeerEditorWidgetSource* SeerEditorManagerWidget::createEditorWidgetTab (const QS editorWidget->sourceArea()->setEditorFont(editorFont()); editorWidget->sourceArea()->setEditorTabSize(editorTabSize()); editorWidget->sourceArea()->setExternalEditorCommand(editorExternalEditorCommand()); + editorWidget->sourceArea()->setAutoSourceReload(editorAutoSourceReload()); editorWidget->sourceArea()->setHighlighterSettings(editorHighlighterSettings()); editorWidget->sourceArea()->setHighlighterEnabled(editorHighlighterEnabled()); editorWidget->sourceArea()->setAlternateDirectories(editorAlternateDirectories()); @@ -1069,6 +1091,7 @@ SeerEditorWidgetSource* SeerEditorManagerWidget::createEditorWidgetTab (const QS editorWidget->sourceArea()->setEditorFont(editorFont()); editorWidget->sourceArea()->setEditorTabSize(editorTabSize()); editorWidget->sourceArea()->setExternalEditorCommand(editorExternalEditorCommand()); + editorWidget->sourceArea()->setAutoSourceReload(editorAutoSourceReload()); editorWidget->sourceArea()->setHighlighterSettings(editorHighlighterSettings()); editorWidget->sourceArea()->setHighlighterEnabled(editorHighlighterEnabled()); editorWidget->sourceArea()->setAlternateDirectories(editorAlternateDirectories()); diff --git a/src/SeerEditorManagerWidget.h b/src/SeerEditorManagerWidget.h index 67c92ef..d32e43b 100644 --- a/src/SeerEditorManagerWidget.h +++ b/src/SeerEditorManagerWidget.h @@ -73,6 +73,8 @@ class SeerEditorManagerWidget : public QWidget, protected Ui::SeerEditorManagerW int editorTabSize () const; void setEditorExternalEditorCommand (const QString& externalEditorCommand); const QString& editorExternalEditorCommand () const; + void setEditorAutoSourceReload (bool flag); + bool editorAutoSourceReload () const; public slots: void handleText (const QString& text); @@ -154,6 +156,7 @@ class SeerEditorManagerWidget : public QWidget, protected Ui::SeerEditorManagerW SeerKeySettings _editorKeySettings; int _editorTabSize; QString _editorExternalEditorCommand; + bool _editorAutoSourceReload; SeerEditorWidgetAssembly* _assemblyWidget; int _assemblyIndex; QString _showAssemblyTabOnStartupMode; diff --git a/src/SeerEditorWidgetSource.cpp b/src/SeerEditorWidgetSource.cpp index 49a0beb..0a68ae6 100644 --- a/src/SeerEditorWidgetSource.cpp +++ b/src/SeerEditorWidgetSource.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "SeerEditorWidgetSource.h" +#include "SeerUtl.h" #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include SeerEditorWidgetSource::SeerEditorWidgetSource(QWidget* parent) : QWidget(parent) { @@ -172,10 +174,28 @@ void SeerEditorWidgetSource::showReloadBar (bool flag) { reloadBarWidget->setStyleSheet("QWidget { background-color : #00AA00; color : #FFFF00; }"); if (flag) { - reloadFilenameLabel->setText("The file \"" + sourceArea()->file() + "\" has changed on disk."); - reloadToolButton->setFocus(Qt::MouseFocusReason); // If 'show', give the reload button the focus. + + int elideLength = 50; + + if (sourceArea()->autoSourceReload()) { + + reloadFilenameLabel->setText("The file \"" + Seer::elideText(sourceArea()->file(),Qt::ElideLeft,elideLength) + "\" has changed on disk. RELOADING..."); + reloadFilenameLabel->setToolTip(sourceArea()->file()); + reloadToolButton->setFocus(Qt::MouseFocusReason); // Give the reload button the focus. + + // Schedule the reload. + QTimer::singleShot(1000, this, &SeerEditorWidgetSource::handleReloadToolButton); + + }else{ + + reloadFilenameLabel->setText("The file \"" + Seer::elideText(sourceArea()->file(),Qt::ElideLeft,elideLength) + "\" has changed on disk."); + reloadFilenameLabel->setToolTip(sourceArea()->file()); + reloadToolButton->setFocus(Qt::MouseFocusReason); // Give the reload button the focus. + } + }else{ reloadFilenameLabel->setText(""); + reloadFilenameLabel->setToolTip(""); } } diff --git a/src/SeerEditorWidgetSource.h b/src/SeerEditorWidgetSource.h index b1650ac..76c4fb5 100644 --- a/src/SeerEditorWidgetSource.h +++ b/src/SeerEditorWidgetSource.h @@ -116,6 +116,8 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit { int editorTabSize () const; void setExternalEditorCommand (const QString& externalEditorCommand); const QString& externalEditorCommand (); + void setAutoSourceReload (bool flag); + bool autoSourceReload () const; SeerCurrentFile readCurrentPosition (); void eraseColorCurrentLine (int lineno); @@ -194,6 +196,7 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit { int _sourceTabSize; QString _externalEditorCommand; + bool _autoSourceReload; }; class SeerEditorWidgetSourceLineNumberArea : public QWidget { diff --git a/src/SeerEditorWidgetSourceAreas.cpp b/src/SeerEditorWidgetSourceAreas.cpp index 60571dc..1ab1b3a 100644 --- a/src/SeerEditorWidgetSourceAreas.cpp +++ b/src/SeerEditorWidgetSourceAreas.cpp @@ -42,6 +42,7 @@ SeerEditorWidgetSourceArea::SeerEditorWidgetSourceArea(QWidget* parent) : SeerPl _sourceHighlighter = 0; _sourceHighlighterEnabled = true; _sourceTabSize = 4; + _autoSourceReload = false; _selectedExpressionId = Seer::createID(); _selectedBreakpointId = Seer::createID(); @@ -60,7 +61,6 @@ SeerEditorWidgetSourceArea::SeerEditorWidgetSourceArea(QWidget* parent) : SeerPl _breakPointArea = new SeerEditorWidgetSourceBreakPointArea(this); _breakPointArea->setMouseTracking(true); - enableLineNumberArea(true); enableBreakPointArea(true); @@ -1694,6 +1694,16 @@ const QString& SeerEditorWidgetSourceArea::externalEditorCommand () { return _externalEditorCommand; } +void SeerEditorWidgetSourceArea::setAutoSourceReload (bool flag) { + + _autoSourceReload = flag; +} + +bool SeerEditorWidgetSourceArea::autoSourceReload () const { + + return _autoSourceReload; +} + void SeerEditorWidgetSourceArea::eraseColorCurrentLine (int lineno) { // Erase color of this line diff --git a/src/SeerMainWindow.cpp b/src/SeerMainWindow.cpp index 2f65f83..6a72b9c 100644 --- a/src/SeerMainWindow.cpp +++ b/src/SeerMainWindow.cpp @@ -755,6 +755,7 @@ void SeerMainWindow::handleSettingsConfiguration () { dlg.setEditorHighlighterEnabled(gdbWidget->editorManager()->editorHighlighterEnabled()); dlg.setEditorHighlighterEnabled(gdbWidget->editorManager()->editorHighlighterEnabled()); dlg.setExternalEditorCommand(gdbWidget->editorManager()->editorExternalEditorCommand()); + dlg.setEditorAutoSourceReload(gdbWidget->editorManager()->editorAutoSourceReload()); dlg.setSourceAlternateDirectories(gdbWidget->sourceAlternateDirectories()); dlg.setSourceIgnoreFilePatterns(gdbWidget->sourceIgnoreFilePatterns()); dlg.setSourceMiscFilePatterns(gdbWidget->sourceMiscFilePatterns()); @@ -800,6 +801,7 @@ void SeerMainWindow::handleSettingsConfiguration () { gdbWidget->editorManager()->setEditorHighlighterSettings(dlg.editorHighlighterSettings()); gdbWidget->editorManager()->setEditorHighlighterEnabled(dlg.editorHighlighterEnabled()); gdbWidget->editorManager()->setEditorExternalEditorCommand(dlg.externalEditorCommand()); + gdbWidget->editorManager()->setEditorAutoSourceReload(dlg.editorAutoSourceReload()); gdbWidget->setSourceAlternateDirectories(dlg.sourceAlternateDirectories()); gdbWidget->setSourceIgnoreFilePatterns(dlg.sourceIgnoreFilePatterns()); gdbWidget->setSourceMiscFilePatterns(dlg.sourceMiscFilePatterns()); @@ -1582,9 +1584,10 @@ void SeerMainWindow::writeConfigSettings () { settings.beginGroup("editor"); { - settings.setValue("font", gdbWidget->editorManager()->editorFont().toString()); - settings.setValue("tabsize", gdbWidget->editorManager()->editorTabSize()); + settings.setValue("font", gdbWidget->editorManager()->editorFont().toString()); + settings.setValue("tabsize", gdbWidget->editorManager()->editorTabSize()); settings.setValue("externaleditorcommand", gdbWidget->editorManager()->editorExternalEditorCommand()); + settings.setValue("autosourcereload", gdbWidget->editorManager()->editorAutoSourceReload()); settings.beginGroup("highlighter"); { @@ -1682,6 +1685,7 @@ void SeerMainWindow::readConfigSettings () { gdbWidget->editorManager()->setEditorTabSize(settings.value("tabsize", 4).toInt()); gdbWidget->editorManager()->setEditorExternalEditorCommand(settings.value("externaleditorcommand").toString()); + gdbWidget->editorManager()->setEditorAutoSourceReload(settings.value("autosourcereload").toBool()); settings.beginGroup("highlighter"); {