From 38f3547fdd497a23d5a8421da3a57e7ae3bbbc4c Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 11 Oct 2016 12:00:04 +0300 Subject: [PATCH] Editor font face setting support - close #12 --- dlangide_msvc.visualdproj | 12 ++++++------ src/dlangide/ui/dsourceedit.d | 7 +++++++ src/dlangide/ui/settings.d | 15 +++++++++++++++ src/dlangide/ui/terminal.d | 1 + src/dlangide/workspace/idesettings.d | 3 +++ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/dlangide_msvc.visualdproj b/dlangide_msvc.visualdproj index ef0455c..18bc307 100644 --- a/dlangide_msvc.visualdproj +++ b/dlangide_msvc.visualdproj @@ -89,7 +89,7 @@ - ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib psapi.lib + ole32.lib kernel32.lib user32.lib @@ -191,7 +191,7 @@ - ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib psapi.lib + ole32.lib kernel32.lib user32.lib @@ -293,7 +293,7 @@ - ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib psapi.lib + ole32.lib kernel32.lib user32.lib @@ -395,7 +395,7 @@ - ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib psapi.lib + ole32.lib kernel32.lib user32.lib @@ -497,7 +497,7 @@ - ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib psapi.lib + ole32.lib kernel32.lib user32.lib @@ -599,7 +599,7 @@ - ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib psapi.lib + ole32.lib kernel32.lib user32.lib diff --git a/src/dlangide/ui/dsourceedit.d b/src/dlangide/ui/dsourceedit.d index 32a81ab..6808f1a 100644 --- a/src/dlangide/ui/dsourceedit.d +++ b/src/dlangide/ui/dsourceedit.d @@ -96,6 +96,13 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener { smartIndentsAfterPaste = _settings.smartIndentsAfterPaste; showWhiteSpaceMarks = _settings.showWhiteSpaceMarks; showTabPositionMarks = _settings.showTabPositionMarks; + string face = _settings.editorFontFace; + if (face == "Default") + face = null; + else if (face) + face ~= ","; + face ~= DEFAULT_SOURCE_EDIT_FONT_FACES; + fontFace = face; } protected EditorTool _editorTool; diff --git a/src/dlangide/ui/settings.d b/src/dlangide/ui/settings.d index 1aad197..f31aafa 100644 --- a/src/dlangide/ui/settings.d +++ b/src/dlangide/ui/settings.d @@ -23,6 +23,7 @@ SettingsPage createSettingsPages() { StringListValue("ru", "Russian"d), StringListValue("es", "Spanish"d), StringListValue("cs", "Čeština"d)]); + ui.addIntComboBox("interface/hintingMode", UIString("Font hinting mode"d), [StringListValue(0, "Normal"d), StringListValue(1, "Force Auto Hint"d), StringListValue(2, "Disabled"d), StringListValue(3, "Light"d)]); ui.addIntComboBox("interface/minAntialiasedFontSize", UIString("Minimum font size for antialiasing"d), @@ -58,6 +59,19 @@ SettingsPage createSettingsPages() { SettingsPage ed = res.addChild("editors", UIString("Editors"d)); SettingsPage texted = ed.addChild("editors/textEditor", UIString("Text Editors"d)); + + // font faces + StringListValue[] faces; + faces ~= StringListValue("Default", "Default"d); + import dlangui.graphics.fonts; + import std.utf : toUTF32; + FontFaceProps[] allFaces = FontManager.instance.getFaces(); + for (int i = 0; i < allFaces.length; i++) { + if (allFaces[i].family == FontFamily.MonoSpace) + faces ~= StringListValue(allFaces[i].face, toUTF32(allFaces[i].face)); + } + texted.addStringComboBox("editors/textEditor/fontFace", UIString("Font face"d), faces); + 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)); @@ -65,6 +79,7 @@ SettingsPage createSettingsPages() { texted.addCheckbox("editors/textEditor/showWhiteSpaceMarks", UIString("Show white space marks"d)); texted.addCheckbox("editors/textEditor/showTabPositionMarks", UIString("Show tab position marks"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"); diff --git a/src/dlangide/ui/terminal.d b/src/dlangide/ui/terminal.d index 9d6b99e..4ad13eb 100644 --- a/src/dlangide/ui/terminal.d +++ b/src/dlangide/ui/terminal.d @@ -2,6 +2,7 @@ module dlangide.ui.terminal; import dlangui.widgets.widget; import dlangui.widgets.controls; +import dlangui.widgets.scrollbar; struct TerminalAttr { ubyte bgColor = 0; diff --git a/src/dlangide/workspace/idesettings.d b/src/dlangide/workspace/idesettings.d index c835f37..a48bffc 100644 --- a/src/dlangide/workspace/idesettings.d +++ b/src/dlangide/workspace/idesettings.d @@ -23,6 +23,7 @@ class IDESettings : SettingsFile { ed.setBooleanDef("smartIndentsAfterPaste", true); ed.setBooleanDef("showWhiteSpaceMarks", true); ed.setBooleanDef("showTabPositionMarks", true); + ed.setStringDef("fontFace", "Default"); Setting ui = uiSettings(); ui.setStringDef("theme", "ide_theme_default"); ui.setStringDef("language", "en"); @@ -157,6 +158,8 @@ class IDESettings : SettingsFile { @property bool showTabPositionMarks() { return editorSettings.getBoolean("showTabPositionMarks", true); } /// set tab position marks enabled flag @property IDESettings showTabPositionMarks(bool enabled) { editorSettings.setBoolean("showTabPositionMarks", enabled); return this; } + /// string value of font face + @property string editorFontFace() { return editorSettings.getString("fontFace", "Default"); }