Add a compiler clone button

dev/git-series/gccdum
Matt Godbolt 7 years ago
parent 9b03547bfe
commit ced7933260

@ -136,6 +136,30 @@ define(function (require) {
this.eventHub.on('resendCompilation', this.onResendCompilation, this);
this.updateCompilerName();
this.updateButtons();
function cloneComponent() {
return {
type: 'component',
componentName: 'compiler',
componentState: self.currentState()
};
}
function findParentRowOrColumn(elem) {
while (elem) {
if (elem.isRow || elem.isColumn) return elem;
elem = elem.parent;
}
return elem;
}
this.container.layoutManager.createDragSource(
this.domRoot.find('.btn.add-compiler'), cloneComponent);
this.domRoot.find('.btn.add-compiler').click(_.bind(function () {
var insertPoint = findParentRowOrColumn(this.container)
|| this.container.layoutManager.root.contentItems[0];
insertPoint.addChild(cloneComponent());
}, this));
}
// Gets the filters that will actually be used (accounting for issues with binary
@ -324,7 +348,7 @@ define(function (require) {
this.updateButtons();
};
Compiler.prototype.saveState = function () {
Compiler.prototype.currentState = function () {
var state = {
compiler: this.compiler ? this.compiler.id : "",
options: this.options,
@ -332,7 +356,11 @@ define(function (require) {
filters: this.filters.get() // NB must *not* be effective filters
};
this.fontScale.addState(state);
this.container.setState(state);
return state;
}
Compiler.prototype.saveState = function () {
this.container.setState(this.currentState());
};
Compiler.prototype.onColours = function (editor, colours) {

@ -93,7 +93,7 @@
class="btn btn-default btn-sm increase-font-size">
<span class="glyphicon glyphicon-sm glyphicon-font"></span>
</button>
<button title="Add a new compiler window (click or drag)"
<button title="Add a new compiler for this source (click or drag)"
class="btn btn-default btn-sm add-compiler">
<span class="glyphicon glyphicon-plus"></span>
</button>
@ -147,6 +147,10 @@
class="btn btn-default btn-sm increase-font-size">
<span class="glyphicon glyphicon-sm glyphicon-font"></span>
</button>
<button title="Clone this compiler window (click or drag)"
class="btn btn-default btn-sm add-compiler">
<span class="glyphicon glyphicon-plus"></span>
</button>
</div>
</div>
<textarea>[Waiting...]</textarea>

Loading…
Cancel
Save