From 35016cb0076fcc50cec0a68d366f377df3092bf9 Mon Sep 17 00:00:00 2001 From: Hans-Albert Maritz Date: Tue, 10 Mar 2015 21:30:20 +1100 Subject: [PATCH] Allow opening all files --- src/dlangide/tools/editortool.d | 15 +++++++++++++++ src/dlangide/ui/dsourceedit.d | 6 ++++++ src/dlangide/ui/frame.d | 16 ++++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/dlangide/tools/editortool.d b/src/dlangide/tools/editortool.d index c9fa8db..ff94ca6 100644 --- a/src/dlangide/tools/editortool.d +++ b/src/dlangide/tools/editortool.d @@ -21,3 +21,18 @@ class EditorTool protected IDEFrame _frame; } + +class DefaultEditorTool : EditorTool +{ + this(IDEFrame frame) { + super(frame); + } + + override bool goToDefinition(DSourceEdit editor, TextPosition caretPosition) { + assert(0); //Go To Definition should not be called for normal files. + } + + override dstring[] getCompletions(DSourceEdit editor, TextPosition caretPosition) { + assert(0); + } +} diff --git a/src/dlangide/ui/dsourceedit.d b/src/dlangide/ui/dsourceedit.d index ef08bdb..a0f0bb3 100644 --- a/src/dlangide/ui/dsourceedit.d +++ b/src/dlangide/ui/dsourceedit.d @@ -15,6 +15,7 @@ import dlangide.workspace.project; import dlangide.ui.commands; import dlangide.ui.settings; import dlangide.tools.d.dsyntax; +import dlangide.tools.editorTool; import std.algorithm; @@ -67,6 +68,11 @@ class DSourceEdit : SourceEdit { smartIndents = _settings.smartIndents; smartIndentsAfterPaste = _settings.smartIndentsAfterPaste; } + + protected EditorTool _editorTool; + @property EditorTool editorTool() { return _editorTool; } + @property EditorTool editorTool(EditorTool tool) { return _editorTool = tool; }; + protected ProjectSourceFile _projectSourceFile; @property ProjectSourceFile projectSourceFile() { return _projectSourceFile; } /// load by filename diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index 23a06df..8e93d48 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -106,7 +106,6 @@ class IDEFrame : AppFrame { override protected void init() { _appName = "dlangide"; - _editorTool = new DEditorTool(this); _dcdServer = new DCDServer(); _settings = new IDESettings(buildNormalizedPath(settingsDir, "settings.json")); _settings.load(); @@ -185,6 +184,10 @@ class IDEFrame : AppFrame { editor.onModifiedStateChangeListener = &onModifiedStateChange; applySettings(editor, settings); _tabs.selectTab(index, true); + if( filename.endsWith(".d") ) + editor.editorTool = new DEditorTool(this); + else + editor.editorTool = new DefaultEditorTool(this); } else { destroy(editor); if (window) @@ -562,12 +565,11 @@ class IDEFrame : AppFrame { caption = "Open Text File"d; FileDialog dlg = createFileDialog(caption); dlg.addFilter(FileFilterEntry(UIString("Source files"d), "*.d;*.dd;*.ddoc;*.dh;*.json;*.xml;*.ini")); + dlg.addFilter(FileFilterEntry(UIString("All files"d), "*.*")); dlg.onDialogResult = delegate(Dialog dlg, const Action result) { if (result.id == ACTION_OPEN.id) { string filename = result.stringParam; - if (isSupportedSourceTextFileFormat(filename)) { - openSourceFile(filename); - } + openSourceFile(filename); } }; dlg.show(); @@ -794,10 +796,8 @@ class IDEFrame : AppFrame { //Log.d("onFilesDropped(", filenames, ")"); bool first = true; for (int i = 0; i < filenames.length; i++) { - if (isSupportedSourceTextFileFormat(filenames[i])) { - openSourceFile(filenames[i], null, first); - first = false; - } + openSourceFile(filenames[i], null, first); + first = false; } }