diff --git a/lib/haxe-state.js b/lib/haxe-state.js index 2afe116..eccb053 100644 --- a/lib/haxe-state.js +++ b/lib/haxe-state.js @@ -143,6 +143,11 @@ module.exports = { this.valid = true; }, + set_hxml_cwd:function(cwd) { + this.hxml_cwd = cwd || path.dirname(file); + log.debug('state hxml cwd to ' + this.hxml_cwd); + }, + set_hxml_content:function(file_content, cwd) { this.unset(true); this.hxml_content = file_content; diff --git a/lib/haxe.js b/lib/haxe.js index 2db0fa5..fd658b5 100644 --- a/lib/haxe.js +++ b/lib/haxe.js @@ -139,6 +139,20 @@ module.exports = { }, //set_hxml_file_from_treeview + set_hxml_cwd_from_treeview: function(opt) { + + var treeview = atom.packages.getLoadedPackage('tree-view'); + if(!treeview) return; + + treeview = require(treeview.mainModulePath); + + var package_obj = treeview.serialize(); + var file_path = package_obj.selectedPath; + + state.set_hxml_cwd( file_path ); + + }, //set_hxml_cwd_from_treeview + build: function(e) { //continue propogation if @@ -269,6 +283,9 @@ module.exports = { this._command('set-hxml-file', this.set_hxml_file_from_treeview.bind(this) ); + this._command('set-hxml-cwd', + this.set_hxml_cwd_from_treeview.bind(this) ); + this._command('clear-project', state.unset.bind(state) ); @@ -289,6 +306,11 @@ module.exports = { { type: 'separator' }, { label: 'Set as active HXML file', command: 'haxe:set-hxml-file', shouldDisplay:this.display_context_tree.bind(this) }, { type: 'separator' } + ], + ".tree-view .directory > div": [ + { type: 'separator' }, + { label: 'Set Haxe build working directory', command: 'haxe:set-hxml-cwd' }, + { type: 'separator' } ] });