diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index b3179047..f2aa614f 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -2623,6 +2623,8 @@
+
+
diff --git a/forms/preferenceeditor.ui b/forms/preferenceeditor.ui
index d9e7fa72..eafffcbf 100644
--- a/forms/preferenceeditor.ui
+++ b/forms/preferenceeditor.ui
@@ -6,8 +6,8 @@
0
0
- 480
- 320
+ 500
+ 500
@@ -15,51 +15,6 @@
- -
-
-
- Preferred Text Editor
-
-
-
-
-
-
- Command
-
-
-
- -
-
-
- The command (including the necessary parameters) to perform the action. See the command parameter legend below for a list of supported parameter variables, which will be substituted when launching the command. When upper-case letters (e.g. %F, $D, %N) are used, the action will be applicable even if more than one item is selected. Esle the action will only be applicable f exactly one item is selected.
-
-
- e.g. code --goto %F:%L
-
-
- true
-
-
-
- -
-
-
- <html><head/><body><p>The command that will be executed when clicking the "Open Map Scripts" button. You may optionally include '%F' and '%L' in the command. '%F' will be substituted with the scripts file path and '%L' will be substituted with a line number. If '%L' is specified then the scripts file will be opened to map script cooresponding to the currently selected event (If the script can be found). If '%F' is <span style=" font-weight:600;">not</span> specified then the map scripts file path will be appended to the end of the command.</p></body></html>
-
-
- false
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
- true
-
-
-
-
-
-
-
@@ -73,6 +28,118 @@
+ -
+
+
+ Preferred Text Editor
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ QFrame::NoFrame
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 482
+ 398
+
+
+
+
+ QLayout::SetMinimumSize
+
+
-
+
+
+ <html><head/><body><p>The command that will be executed when clicking the <span style=" font-weight:600;">Open Map Scripts</span> button<span style=" font-weight:600;">. %F</span> will be substituted with the scripts file path and <span style=" font-weight:600;">%L</span> will be substituted with the line number of the event that is currently selected. <span style=" font-weight:600;">%F </span><span style=" font-style:italic;">must</span> be specified if <span style=" font-weight:600;">%L</span> is specified. If <span style=" font-weight:600;">%F</span> is <span style=" font-style:italic;">not</span> specified then the scripts file path will be appended to the end of the command.</p></body></html>
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
+
+ true
+
+
+
+ -
+
+
+ The shell command for your preferred text editor to open a file to a specific line number (possibly an absolute path if the program doesn't exist in your PATH).
+
+
+ e.g. code --goto %F:%L
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>The command that will be executed when clicking <span style=" font-weight:600;">Open Project in Text Editor</span> in the <span style=" font-weight:600;">Tools</span> menu. <span style=" font-weight:600;">%D</span> will be substituted with the current project's root directory. If <span style=" font-weight:600;">%D</span> is <span style=" font-style:italic;">not</span> specified then the project directory will be appended to the end of the command.</p></body></html>
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
+
+ true
+
+
+
+ -
+
+
+ Open Directory Command
+
+
+
+ -
+
+
+ The shell command for your preferred text editor (possibly an absolute path if the program doesn't exist in your PATH).
+
+
+ e.g. code %D
+
+
+
+ -
+
+
+ Goto Line Command
+
+
+
+
+
+
+
+
+
+
-
diff --git a/include/config.h b/include/config.h
index bb740d41..37c5fb25 100644
--- a/include/config.h
+++ b/include/config.h
@@ -45,6 +45,8 @@ public:
this->monitorFiles = true;
this->regionMapDimensions = QSize(32, 20);
this->theme = "default";
+ this->textEditorOpenFolder = "";
+ this->textEditorGotoLine = "";
}
void setRecentProject(QString project);
void setRecentMap(QString map);
@@ -61,7 +63,8 @@ public:
void setMonitorFiles(bool monitor);
void setRegionMapDimensions(int width, int height);
void setTheme(QString theme);
- void setTextEditorCommandTemplate(const QString &commandTemplate);
+ void setTextEditorOpenFolder(const QString &command);
+ void setTextEditorGotoLine(const QString &command);
QString getRecentProject();
QString getRecentMap();
MapSortOrder getMapSortOrder();
@@ -77,7 +80,8 @@ public:
bool getMonitorFiles();
QSize getRegionMapDimensions();
QString getTheme();
- QString getTextEditorCommandTemplate();
+ QString getTextEditorOpenFolder();
+ QString getTextEditorGotoLine();
protected:
virtual QString getConfigFilepath() override;
virtual void parseConfigKeyValue(QString key, QString value) override;
@@ -109,7 +113,8 @@ private:
bool monitorFiles;
QSize regionMapDimensions;
QString theme;
- QString textEditorCommandTemplate;
+ QString textEditorOpenFolder;
+ QString textEditorGotoLine;
};
extern PorymapConfig porymapConfig;
diff --git a/include/editor.h b/include/editor.h
index 6e04262e..8dfa91ae 100644
--- a/include/editor.h
+++ b/include/editor.h
@@ -155,6 +155,7 @@ public:
public slots:
void openMapScripts() const;
+ void openProjectInTextEditor() const;
void maskNonVisibleConnectionTiles();
private:
@@ -184,7 +185,9 @@ private:
QString getMovementPermissionText(uint16_t collision, uint16_t elevation);
QString getMetatileDisplayMessage(uint16_t metatileId);
bool eventLimitReached(Map *, QString);
- QString constructTextEditorCommand(QString commandTemplate, const QString &path) const;
+ bool startDetachedProcess(const QString &command,
+ const QString &workingDirectory = QString(),
+ qint64 *pid = nullptr) const;
private slots:
void onMapStartPaint(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
diff --git a/src/config.cpp b/src/config.cpp
index 24798f7c..831e5507 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -187,8 +187,10 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
}
} else if (key == "theme") {
this->theme = value;
- } else if (key == "text_editor") {
- this->textEditorCommandTemplate = value;
+ } else if (key == "text_editor_open_directory") {
+ this->textEditorOpenFolder = value;
+ } else if (key == "text_editor_goto_line") {
+ this->textEditorGotoLine = value;
} else {
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
}
@@ -218,7 +220,8 @@ QMap PorymapConfig::getKeyValueMap() {
map.insert("region_map_dimensions", QString("%1x%2").arg(this->regionMapDimensions.width())
.arg(this->regionMapDimensions.height()));
map.insert("theme", this->theme);
- map.insert("text_editor", this->textEditorCommandTemplate);
+ map.insert("text_editor_open_directory", this->textEditorOpenFolder);
+ map.insert("text_editor_goto_line", this->textEditorGotoLine);
return map;
}
@@ -319,8 +322,13 @@ void PorymapConfig::setTheme(QString theme) {
this->theme = theme;
}
-void PorymapConfig::setTextEditorCommandTemplate(const QString &commandTemplate) {
- this->textEditorCommandTemplate = commandTemplate;
+void PorymapConfig::setTextEditorOpenFolder(const QString &command) {
+ this->textEditorOpenFolder = command;
+ this->save();
+}
+
+void PorymapConfig::setTextEditorGotoLine(const QString &command) {
+ this->textEditorGotoLine = command;
this->save();
}
@@ -406,8 +414,12 @@ QString PorymapConfig::getTheme() {
return this->theme;
}
-QString PorymapConfig::getTextEditorCommandTemplate() {
- return this->textEditorCommandTemplate;
+QString PorymapConfig::getTextEditorOpenFolder() {
+ return this->textEditorOpenFolder;
+}
+
+QString PorymapConfig::getTextEditorGotoLine() {
+ return this->textEditorGotoLine;
}
const QMap baseGameVersionMap = {
diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp
index 5dc4f176..733cf5fe 100644
--- a/src/core/parseutil.cpp
+++ b/src/core/parseutil.cpp
@@ -434,7 +434,7 @@ int ParseUtil::getRawScriptLineNumber(QString text, const QString &scriptLabel)
removeStringLiterals(text);
removeLineComments(text, "@");
- static const QRegularExpression re_incScriptLabel("(?