mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 17:07:32 -06:00
+2
-2
@@ -114,7 +114,7 @@ define(function (require) {
|
||||
container.on('resize', this.resize, this);
|
||||
container.on('shown', this.resize, this);
|
||||
container.on('open', function () {
|
||||
self.eventHub.emit('compilerOpen', self.id);
|
||||
self.eventHub.emit('compilerOpen', self.id, self.sourceEditorId);
|
||||
self.updateFontScale();
|
||||
});
|
||||
this.eventHub.on('editorChange', this.onEditorChange, this);
|
||||
@@ -438,8 +438,8 @@ define(function (require) {
|
||||
Compiler.prototype.currentState = function () {
|
||||
var state = {
|
||||
compiler: this.compiler ? this.compiler.id : "",
|
||||
source: this.sourceEditorId,
|
||||
options: this.options,
|
||||
source: this.editor,
|
||||
filters: this.filters.get() // NB must *not* be effective filters
|
||||
};
|
||||
this.fontScale.addState(state);
|
||||
|
||||
+13
-5
@@ -46,6 +46,7 @@ define(function (require) {
|
||||
this.domRoot.html($('#codeEditor').html());
|
||||
this.eventHub = hub.createEventHub();
|
||||
this.settings = {};
|
||||
this.ourCompilers = {}
|
||||
|
||||
this.widgetsByCompiler = {};
|
||||
this.asmByCompiler = {};
|
||||
@@ -144,6 +145,7 @@ define(function (require) {
|
||||
this.eventHub.on('selectLine', this.onSelectLine, this);
|
||||
|
||||
this.eventHub.on('settingsChange', this.onSettingsChange, this);
|
||||
this.eventHub.emit('requestSettings');
|
||||
|
||||
// NB a new compilerConfig needs to be created every time; else the state is shared
|
||||
// between all compilers created this way. That leads to some nasty-to-find state
|
||||
@@ -231,7 +233,16 @@ define(function (require) {
|
||||
this.eventHub.emit('colours', this.id, colours, this.settings.colourScheme);
|
||||
};
|
||||
|
||||
Editor.prototype.onCompilerOpen = function (compilerId, editorId) {
|
||||
if (editorId === this.id) {
|
||||
// On any compiler open, rebroadcast our state in case they need to know it.
|
||||
this.maybeEmitChange(true);
|
||||
this.ourCompilers[compilerId] = true;
|
||||
}
|
||||
};
|
||||
|
||||
Editor.prototype.onCompilerClose = function (compilerId) {
|
||||
if (!this.ourCompilers[compilerId]) return;
|
||||
monaco.editor.setModelMarkers(this.editor.getModel(), compilerId, []);
|
||||
delete this.widgetsByCompiler[compilerId];
|
||||
delete this.asmByCompiler[compilerId];
|
||||
@@ -239,16 +250,13 @@ define(function (require) {
|
||||
this.numberUsedLines();
|
||||
};
|
||||
|
||||
Editor.prototype.onCompilerOpen = function () {
|
||||
// On any compiler open, rebroadcast our state in case they need to know it.
|
||||
this.maybeEmitChange(true);
|
||||
};
|
||||
|
||||
Editor.prototype.onCompiling = function (compilerId) {
|
||||
if (!this.ourCompilers[compilerId]) return;
|
||||
this.busyCompilers[compilerId] = true;
|
||||
};
|
||||
|
||||
Editor.prototype.onCompileResponse = function (compilerId, compiler, result) {
|
||||
if (!this.ourCompilers[compilerId]) return;
|
||||
this.busyCompilers[compilerId] = false;
|
||||
var output = (result.stdout || []).concat(result.stderr || []);
|
||||
var widgets = _.compact(_.map(output, function (obj) {
|
||||
|
||||
+23
-13
@@ -65,6 +65,28 @@ define(function (require) {
|
||||
var Raven = require('raven-js');
|
||||
var settings = require('./settings');
|
||||
|
||||
function setupSettings(eventHub) {
|
||||
var currentSettings = {};
|
||||
try {
|
||||
currentSettings = JSON.parse(window.localStorage.getItem('settings'));
|
||||
} catch (e) {
|
||||
}
|
||||
function onChange(settings) {
|
||||
currentSettings = settings;
|
||||
try {
|
||||
window.localStorage.setItem('settings', JSON.stringify(settings));
|
||||
} catch (e) {
|
||||
}
|
||||
eventHub.emit('settingsChange', settings);
|
||||
}
|
||||
|
||||
eventHub.on('requestSettings', function () {
|
||||
eventHub.emit('settingsChange', currentSettings);
|
||||
});
|
||||
|
||||
settings($('#settings'), currentSettings, onChange);
|
||||
}
|
||||
|
||||
function start() {
|
||||
analytics.initialise();
|
||||
sharing.initialise();
|
||||
@@ -152,19 +174,7 @@ define(function (require) {
|
||||
|
||||
new clipboard('.btn.clippy');
|
||||
|
||||
settings($('#settings'), function () {
|
||||
try {
|
||||
return JSON.parse(window.localStorage.getItem('settings'));
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}(), function (settings) {
|
||||
try {
|
||||
window.localStorage.setItem('settings', JSON.stringify(settings));
|
||||
} catch (e) {
|
||||
}
|
||||
layout.eventHub.emit('settingsChange', settings);
|
||||
});
|
||||
setupSettings(layout.eventHub);
|
||||
|
||||
sharing.initShareButton($('#share'), layout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user