Merge pull request #44 from Freakazo/master

Allow opening all files
This commit is contained in:
Vadim Lopatin 2015-03-10 13:37:33 +03:00
commit 93255d7a10
3 changed files with 29 additions and 8 deletions

View File

@ -21,3 +21,18 @@ class EditorTool
protected IDEFrame _frame; 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);
}
}

View File

@ -15,6 +15,7 @@ import dlangide.workspace.project;
import dlangide.ui.commands; import dlangide.ui.commands;
import dlangide.ui.settings; import dlangide.ui.settings;
import dlangide.tools.d.dsyntax; import dlangide.tools.d.dsyntax;
import dlangide.tools.editorTool;
import std.algorithm; import std.algorithm;
@ -67,6 +68,11 @@ class DSourceEdit : SourceEdit {
smartIndents = _settings.smartIndents; smartIndents = _settings.smartIndents;
smartIndentsAfterPaste = _settings.smartIndentsAfterPaste; smartIndentsAfterPaste = _settings.smartIndentsAfterPaste;
} }
protected EditorTool _editorTool;
@property EditorTool editorTool() { return _editorTool; }
@property EditorTool editorTool(EditorTool tool) { return _editorTool = tool; };
protected ProjectSourceFile _projectSourceFile; protected ProjectSourceFile _projectSourceFile;
@property ProjectSourceFile projectSourceFile() { return _projectSourceFile; } @property ProjectSourceFile projectSourceFile() { return _projectSourceFile; }
/// load by filename /// load by filename

View File

@ -106,7 +106,6 @@ class IDEFrame : AppFrame {
override protected void init() { override protected void init() {
_appName = "dlangide"; _appName = "dlangide";
_editorTool = new DEditorTool(this);
_dcdServer = new DCDServer(); _dcdServer = new DCDServer();
_settings = new IDESettings(buildNormalizedPath(settingsDir, "settings.json")); _settings = new IDESettings(buildNormalizedPath(settingsDir, "settings.json"));
_settings.load(); _settings.load();
@ -185,6 +184,10 @@ class IDEFrame : AppFrame {
editor.onModifiedStateChangeListener = &onModifiedStateChange; editor.onModifiedStateChangeListener = &onModifiedStateChange;
applySettings(editor, settings); applySettings(editor, settings);
_tabs.selectTab(index, true); _tabs.selectTab(index, true);
if( filename.endsWith(".d") )
editor.editorTool = new DEditorTool(this);
else
editor.editorTool = new DefaultEditorTool(this);
} else { } else {
destroy(editor); destroy(editor);
if (window) if (window)
@ -562,12 +565,11 @@ class IDEFrame : AppFrame {
caption = "Open Text File"d; caption = "Open Text File"d;
FileDialog dlg = createFileDialog(caption); FileDialog dlg = createFileDialog(caption);
dlg.addFilter(FileFilterEntry(UIString("Source files"d), "*.d;*.dd;*.ddoc;*.dh;*.json;*.xml;*.ini")); 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) { dlg.onDialogResult = delegate(Dialog dlg, const Action result) {
if (result.id == ACTION_OPEN.id) { if (result.id == ACTION_OPEN.id) {
string filename = result.stringParam; string filename = result.stringParam;
if (isSupportedSourceTextFileFormat(filename)) { openSourceFile(filename);
openSourceFile(filename);
}
} }
}; };
dlg.show(); dlg.show();
@ -794,10 +796,8 @@ class IDEFrame : AppFrame {
//Log.d("onFilesDropped(", filenames, ")"); //Log.d("onFilesDropped(", filenames, ")");
bool first = true; bool first = true;
for (int i = 0; i < filenames.length; i++) { for (int i = 0; i < filenames.length; i++) {
if (isSupportedSourceTextFileFormat(filenames[i])) { openSourceFile(filenames[i], null, first);
openSourceFile(filenames[i], null, first); first = false;
first = false;
}
} }
} }