mirror of
https://github.com/epasveer/seer.git
synced 2026-08-30 00:50:42 +08:00
Add an option to automatically reload the source file if it's changed.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -262,15 +262,22 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="autoReloadSourceFileLabel">
|
||||
<property name="text">
|
||||
<string>Auto Source Reload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="externalEditorCommandLabel">
|
||||
<property name="text">
|
||||
<string>External Editor Command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QHistoryLineEdit" name="externalEditorCommandLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Command to launch external editor.</string>
|
||||
@@ -286,6 +293,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="autoReloadSourceFileCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Automatically reload source files if they are externally modified.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
@@ -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></string>
|
||||
<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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "SeerEditorWidgetSource.h"
|
||||
#include "SeerUtl.h"
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QTextBlock>
|
||||
@@ -19,6 +20,7 @@
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
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("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"); {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user