mirror of https://github.com/buggins/dlangide.git
project settings
This commit is contained in:
parent
60a49d3b79
commit
a32119b914
src/dlangide
|
@ -7,6 +7,7 @@ import dlangide.ui.outputpanel;
|
|||
import dlangide.builders.extprocess;
|
||||
import dlangui.widgets.appframe;
|
||||
import std.algorithm;
|
||||
import std.array;
|
||||
import core.thread;
|
||||
import std.string;
|
||||
import std.conv;
|
||||
|
@ -24,11 +25,17 @@ class Builder : BackgroundOperationWatcher {
|
|||
protected bool _verbose;
|
||||
protected BuildResultListener _listener;
|
||||
protected int _exitCode = int.min;
|
||||
protected string _toolchain;
|
||||
protected string _arch;
|
||||
|
||||
@property Project project() { return _project; }
|
||||
@property void project(Project p) { _project = p; }
|
||||
|
||||
this(AppFrame frame, Project project, OutputPanel log, ProjectConfiguration projectConfig, BuildConfiguration buildConfig, BuildOperation buildOp, bool verbose, BuildResultListener listener = null) {
|
||||
this(AppFrame frame, Project project, OutputPanel log, ProjectConfiguration projectConfig, BuildConfiguration buildConfig,
|
||||
BuildOperation buildOp, bool verbose,
|
||||
string toolchain = null,
|
||||
string arch = null,
|
||||
BuildResultListener listener = null) {
|
||||
super(frame);
|
||||
_listener = listener;
|
||||
_projectConfig = projectConfig;
|
||||
|
@ -37,6 +44,8 @@ class Builder : BackgroundOperationWatcher {
|
|||
_verbose = verbose;
|
||||
_project = project;
|
||||
_log = log;
|
||||
_toolchain = toolchain;
|
||||
_arch = arch;
|
||||
_extprocess = new ExternalProcess();
|
||||
_box = new ProtectedTextStorage();
|
||||
}
|
||||
|
@ -67,6 +76,10 @@ class Builder : BackgroundOperationWatcher {
|
|||
if (_buildOp == BuildOperation.Rebuild) {
|
||||
params ~= "--force".dup;
|
||||
}
|
||||
if (!_arch.empty)
|
||||
params ~= ("--arch=" ~ _arch).dup;
|
||||
if (!_toolchain.empty)
|
||||
params ~= ("--compiler=" ~ _toolchain).dup;
|
||||
} else if (_buildOp == BuildOperation.Clean) {
|
||||
params ~= "clean".dup;
|
||||
} else if (_buildOp == BuildOperation.Run) {
|
||||
|
|
|
@ -733,6 +733,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener {
|
|||
case IDEActions.EditPreferences:
|
||||
showPreferences();
|
||||
return true;
|
||||
case IDEActions.ProjectSettings:
|
||||
showProjectSettings();
|
||||
return true;
|
||||
case IDEActions.FindText:
|
||||
Log.d("Opening Search Field");
|
||||
import dlangide.ui.searchPanel;
|
||||
|
@ -935,6 +938,24 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener {
|
|||
dlg.show();
|
||||
}
|
||||
|
||||
void showProjectSettings() {
|
||||
if (!currentWorkspace)
|
||||
return;
|
||||
Project project = currentWorkspace.startupProject;
|
||||
if (!project)
|
||||
return;
|
||||
Setting s = project.settings.copySettings();
|
||||
SettingsDialog dlg = new SettingsDialog(UIString(project.name ~ " settings"d), window, s, createProjectSettingsPages());
|
||||
dlg.dialogResult = delegate(Dialog dlg, const Action result) {
|
||||
if (result.id == ACTION_APPLY.id) {
|
||||
//Log.d("settings after edit:\n", s.toJSON(true));
|
||||
project.settings.applySettings(s);
|
||||
project.settings.save();
|
||||
}
|
||||
};
|
||||
dlg.show();
|
||||
}
|
||||
|
||||
void applySettings(IDESettings settings) {
|
||||
for (int i = _tabs.tabCount - 1; i >= 0; i--) {
|
||||
DSourceEdit ed = cast(DSourceEdit)_tabs.tabBody(i);
|
||||
|
@ -1059,7 +1080,15 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener {
|
|||
_logPanel.logLine("No project is opened");
|
||||
return;
|
||||
}
|
||||
Builder op = new Builder(this, currentWorkspace.startupProject, _logPanel, currentWorkspace.projectConfiguration, currentWorkspace.buildConfiguration, buildOp, false, listener);
|
||||
ProjectSettings projectSettings = currentWorkspace.startupProject.settings;
|
||||
string toolchain = projectSettings.getToolchain(_settings);
|
||||
string arch = projectSettings.getArch(_settings);
|
||||
bool verbose = projectSettings.buildVerbose;
|
||||
Builder op = new Builder(this, currentWorkspace.startupProject, _logPanel, currentWorkspace.projectConfiguration, currentWorkspace.buildConfiguration, buildOp,
|
||||
verbose,
|
||||
toolchain,
|
||||
arch,
|
||||
listener);
|
||||
setBackgroundOperation(op);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,14 @@ public import dlangide.workspace.workspacesettings;
|
|||
/// create DlangIDE settings pages tree
|
||||
SettingsPage createSettingsPages() {
|
||||
SettingsPage res = new SettingsPage("", UIString(""d));
|
||||
|
||||
SettingsPage ed = res.addChild("editors", UIString("Editors"d));
|
||||
SettingsPage texted = ed.addChild("editors/textEditor", UIString("Text Editors"d));
|
||||
texted.addNumberEdit("editors/textEditor/tabSize", UIString("Tab size"d), 1, 16, 4);
|
||||
texted.addCheckbox("editors/textEditor/useSpacesForTabs", UIString("Use spaces for tabs"d));
|
||||
texted.addCheckbox("editors/textEditor/smartIndents", UIString("Smart indents"d));
|
||||
texted.addCheckbox("editors/textEditor/smartIndentsAfterPaste", UIString("Smart indent after paste"d));
|
||||
|
||||
SettingsPage dlang = res.addChild("dlang", UIString("D"d));
|
||||
SettingsPage dub = dlang.addChild("dlang/dub", UIString("DUB"d));
|
||||
dub.addExecutableFileNameEdit("dlang/dub/executable", UIString("DUB executable"d), "dub");
|
||||
|
@ -82,6 +84,7 @@ SettingsPage createSettingsPages() {
|
|||
/// create DlangIDE settings pages tree
|
||||
SettingsPage createProjectSettingsPages() {
|
||||
SettingsPage res = new SettingsPage("", UIString(""d));
|
||||
|
||||
SettingsPage build = res.addChild("build", UIString("Build"d));
|
||||
build.addStringComboBox("build/toolchain", UIString("Toolchain"d), [
|
||||
StringListValue("default", "Default"d),
|
||||
|
@ -91,10 +94,13 @@ SettingsPage createProjectSettingsPages() {
|
|||
build.addStringComboBox("build/arch", UIString("Architecture"d), [
|
||||
StringListValue("default", "Default"d),
|
||||
StringListValue("x86", "x86"d),
|
||||
StringListValue("x86_64", "x86_6"d)]);
|
||||
StringListValue("x86_64", "x86_64"d)]);
|
||||
build.addCheckbox("build/verbose", UIString("Verbose"d), true);
|
||||
|
||||
SettingsPage dbg = res.addChild("debug", UIString("Run and Debug"d));
|
||||
dbg.addStringEdit("debug/run_args", UIString("Command line args"d), "");
|
||||
dbg.addDirNameEdit("debug/working_dir", UIString("Working directory"d), "");
|
||||
dbg.addCheckbox("debug/external_console", UIString("Run in external console"d), true);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -169,9 +169,9 @@ class IDESettings : SettingsFile {
|
|||
if (toolchainName.equal("dmd"))
|
||||
return dmdToolchainSettings.getString("executable", "dmd");
|
||||
if (toolchainName.equal("gdc"))
|
||||
return dmdToolchainSettings.getString("executable", "gdc");
|
||||
return gdcToolchainSettings.getString("executable", "gdc");
|
||||
if (toolchainName.equal("ldc"))
|
||||
return dmdToolchainSettings.getString("executable", "ldc2");
|
||||
return ldcToolchainSettings.getString("executable", "ldc2");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module dlangide.workspace.project;
|
||||
|
||||
import dlangide.workspace.workspace;
|
||||
import dlangide.workspace.projectsettings;
|
||||
import dlangui.core.logger;
|
||||
import dlangui.core.collections;
|
||||
import dlangui.core.settings;
|
||||
|
@ -332,6 +333,7 @@ class Project : WorkspaceItem {
|
|||
protected ProjectFolder _items;
|
||||
protected ProjectSourceFile _mainSourceFile;
|
||||
protected SettingsFile _projectFile;
|
||||
protected ProjectSettings _settingsFile;
|
||||
protected bool _isDependency;
|
||||
protected string _dependencyVersion;
|
||||
|
||||
|
@ -348,6 +350,20 @@ class Project : WorkspaceItem {
|
|||
_projectFile = new SettingsFile(fname);
|
||||
}
|
||||
|
||||
@property ProjectSettings settings() {
|
||||
if (!_settingsFile) {
|
||||
_settingsFile = new ProjectSettings(settingsFileName);
|
||||
_settingsFile.updateDefaults();
|
||||
_settingsFile.load();
|
||||
_settingsFile.save();
|
||||
}
|
||||
return _settingsFile;
|
||||
}
|
||||
|
||||
@property string settingsFileName() {
|
||||
return buildNormalizedPath(dir, toUTF8(name) ~ ".settings");
|
||||
}
|
||||
|
||||
@property bool isDependency() { return _isDependency; }
|
||||
@property string dependencyVersion() { return _dependencyVersion; }
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class ProjectSettings : SettingsFile {
|
|||
Setting build = buildSettings();
|
||||
build.setStringDef("toolchain", "default");
|
||||
build.setStringDef("arch", "default");
|
||||
build.setBooleanDef("verbose", false);
|
||||
Setting dbg = debugSettings();
|
||||
dbg.setBooleanDef("external_console", true);
|
||||
}
|
||||
|
@ -36,6 +37,10 @@ class ProjectSettings : SettingsFile {
|
|||
return res;
|
||||
}
|
||||
|
||||
@property bool buildVerbose() {
|
||||
return buildSettings.getBoolean("verbose", false);
|
||||
}
|
||||
|
||||
string getToolchain(IDESettings idesettings) {
|
||||
string cfg = buildSettings.getString("toolchain");
|
||||
return idesettings.getToolchainSettings(cfg);
|
||||
|
|
Loading…
Reference in New Issue