mirror of https://github.com/buggins/dlangide.git
more settings
This commit is contained in:
parent
7778bd3ecf
commit
6dd4ac7fe6
|
@ -2,6 +2,10 @@ module dlangide.ui.settings;
|
||||||
|
|
||||||
import dlangui.core.settings;
|
import dlangui.core.settings;
|
||||||
|
|
||||||
|
|
||||||
|
const AVAILABLE_THEMES = ["theme_default", "theme_dark"];
|
||||||
|
const AVAILABLE_LANGUAGES = ["en", "ru"];
|
||||||
|
|
||||||
class IDESettings : SettingsFile {
|
class IDESettings : SettingsFile {
|
||||||
|
|
||||||
this(string filename) {
|
this(string filename) {
|
||||||
|
@ -12,6 +16,9 @@ class IDESettings : SettingsFile {
|
||||||
Setting ed = editorSettings();
|
Setting ed = editorSettings();
|
||||||
ed.setBooleanDef("useSpacesForTabs", true);
|
ed.setBooleanDef("useSpacesForTabs", true);
|
||||||
ed.setIntegerDef("tabSize", 4);
|
ed.setIntegerDef("tabSize", 4);
|
||||||
|
Setting ui = uiSettings();
|
||||||
|
ui.setStringDef("theme", "theme_default");
|
||||||
|
ui.setStringDef("language", "en");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// override to do something after loading - e.g. set defaults
|
/// override to do something after loading - e.g. set defaults
|
||||||
|
@ -23,6 +30,11 @@ class IDESettings : SettingsFile {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property Setting uiSettings() {
|
||||||
|
Setting res = _setting.objectByPath("interface", true);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static int limitInt(long value, int minvalue, int maxvalue) {
|
static int limitInt(long value, int minvalue, int maxvalue) {
|
||||||
if (value < minvalue)
|
if (value < minvalue)
|
||||||
return minvalue;
|
return minvalue;
|
||||||
|
@ -31,6 +43,34 @@ class IDESettings : SettingsFile {
|
||||||
return cast(int)value;
|
return cast(int)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string limitString(string value, const string[] values) {
|
||||||
|
assert(values.length > 0);
|
||||||
|
foreach(v; values)
|
||||||
|
if (v.equal(value))
|
||||||
|
return value;
|
||||||
|
return values[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// theme
|
||||||
|
@property string uiTheme() {
|
||||||
|
return limitString(uiSettings.getString("theme", "theme_default"), AVAILABLE_THEMES);
|
||||||
|
}
|
||||||
|
/// theme
|
||||||
|
@property IDESettings uiTheme(string v) {
|
||||||
|
uiSettings.setString("theme", limitString(v, AVAILABLE_THEMES));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// language
|
||||||
|
@property string uiLanguage() {
|
||||||
|
return limitString(uiSettings.getString("language", "en"), AVAILABLE_LANGUAGES);
|
||||||
|
}
|
||||||
|
/// language
|
||||||
|
@property IDESettings uiLanguage(string v) {
|
||||||
|
uiSettings.setString("language", limitString(v, AVAILABLE_LANGUAGES));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/// text editor setting, true if need to insert spaces instead of tabs
|
/// text editor setting, true if need to insert spaces instead of tabs
|
||||||
@property bool useSpacesForTabs() {
|
@property bool useSpacesForTabs() {
|
||||||
return editorSettings.getBoolean("useSpacesForTabs", true);
|
return editorSettings.getBoolean("useSpacesForTabs", true);
|
||||||
|
|
Loading…
Reference in New Issue