From 4749e25d18e7e4f96fd5b180b62e314c481a0007 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sun, 26 Mar 2017 07:25:47 -0500 Subject: [PATCH 1/9] Restart on pug file changes too --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index afabfd56..52d2f914 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ clean: $(MAKE) -C c-preload clean run: prereqs - $(NODE) ./node_modules/.bin/supervisor -w app.js,lib,etc/config -e 'js|node|properties' --exec $(NODE) -- ./app.js --language $(LANG) $(EXTRA_ARGS) + $(NODE) ./node_modules/.bin/supervisor -w app.js,lib,etc/config -e 'js|node|properties|pug' --exec $(NODE) -- ./app.js --language $(LANG) $(EXTRA_ARGS) HASH := $(shell git rev-parse HEAD) dist: prereqs From 6cfd8a4c41ddec71bcf687213fa29f7b48a8800f Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sun, 26 Mar 2017 07:27:24 -0500 Subject: [PATCH 2/9] Fix up indentation (thanks @RabsRincon) --- views/popups.pug | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/views/popups.pug b/views/popups.pug index 5dff0ab2..8edab1e4 100644 --- a/views/popups.pug +++ b/views/popups.pug @@ -76,14 +76,14 @@ input.hoverShowSource(type="checkbox") | Highlight linked code lines on hover h4 Compilation - .form-group(role="group") - .form-control.checkbox - label - input.colourise(type="checkbox") - | Colourise lines so one can see how the source maps to the output - .form-control - label - | Colour scheme: - select.colourScheme + .form-group(role="group") + .form-control.checkbox + label + input.colourise(type="checkbox") + | Colourise lines so one can see how the source maps to the output + .form-control + label + | Colour scheme: + select.colourScheme .modal-footer button.btn.btn-default(type="button" data-dismiss="modal") Close From 60e1a86eacee692d835c1126ccf64db2dc2bf7ec Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sun, 26 Mar 2017 08:37:59 -0500 Subject: [PATCH 3/9] Diff improvements Names compilers, presents nicer diff dropdown. Fixes #269 Fixes #268 --- static/compiler.js | 4 ++-- static/diff.js | 48 +++++++++++++++++++++++++++++++++++++++------ static/explorer.css | 28 ++++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/static/compiler.js b/static/compiler.js index 266439b2..5c64fe6f 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -443,7 +443,7 @@ define(function (require) { }; Compiler.prototype.sendCompiler = function () { - this.eventHub.emit('compiler', this.id, this.compiler, this.options); + this.eventHub.emit('compiler', this.id, this.compiler, this.options, this.sourceEditorId); }; Compiler.prototype.onEditorClose = function (editor) { @@ -490,7 +490,7 @@ define(function (require) { Compiler.prototype.updateCompilerName = function () { var compilerName = this.compiler ? this.compiler.name : "no compiler set"; var compilerVersion = this.compiler ? this.compiler.version : ""; - this.container.setTitle("#" + this.sourceEditorId + " with " + compilerName); + this.container.setTitle(compilerName + " (Editor #" + this.sourceEditorId + ", Compiler #" + this.id + ")"); this.domRoot.find(".full-compiler-name").text(compilerVersion); }; diff --git a/static/diff.js b/static/diff.js index 118365ef..50f87c48 100644 --- a/static/diff.js +++ b/static/diff.js @@ -72,7 +72,18 @@ define(function (require) { labelField: 'name', searchField: ['name'], options: [], - items: [] + items: [], + render: { + option: function (item, escape) { + return '
' + + '' + escape(item.compiler.name) + '' + + '' + escape(item.options) + '' + + '
    ' + + '
  • Editor #' + escape(item.editorId) + '
  • ' + + '
  • Compiler #' + escape(item.id) + '
  • ' + + '
'; + } + } }).on('change', function () { var compiler = self.compilers[$(this).val()]; if (!compiler) return; @@ -83,9 +94,7 @@ define(function (require) { self.rhs.compiler = compiler; self.rhs.id = compiler.id; } - self.eventHub.emit('resendCompilation', compiler.id); - self.updateCompilerNames(); - self.updateState(); + self.onDiffSelect(compiler.id); }); this.selectize = {lhs: selectize[0].selectize, rhs: selectize[1].selectize}; @@ -119,6 +128,12 @@ define(function (require) { }); }; + Diff.prototype.onDiffSelect = function (id) { + this.eventHub.emit('resendCompilation', id); + this.updateCompilerNames(); + this.updateState(); + }; + Diff.prototype.onCompileResult = function (id, compiler, result) { // both sides must be updated, don't be tempted to rewrite this as // var changes = lhs.update() || rhs.update(); @@ -129,10 +144,31 @@ define(function (require) { } }; - Diff.prototype.onCompiler = function (id, compiler, options) { + Diff.prototype.onCompiler = function (id, compiler, options, editorId) { if (!compiler) return; options = options || ""; - this.compilers[id] = {id: id, name: compiler.name + " " + options}; + var name = compiler.name + " " + options; + // TODO: selectize doesn't play nicely with CSS tricks for truncation; this is the best I can do + // There's a plugin at: http://www.benbybenjacobs.com/blog/2014/04/09/no-wrap-plugin-for-selectize-dot-js + // but it doesn't look easy to integrate. + var maxLength = 30; + if (name.length > maxLength - 3) name = name.substr(0, maxLength - 3) + "..."; + this.compilers[id] = { + id: id, + name: name, + options: options, + editorId: editorId, + compiler: compiler + }; + if (!this.lhs.id) { + this.lhs.compiler = this.compilers[id]; + this.lhs.id = id; + this.onDiffSelect(id); + } else if (!this.rhs.id) { + this.rhs.compiler = this.compilers[id]; + this.rhs.id = id; + this.onDiffSelect(id); + } this.updateCompilers(); }; diff --git a/static/explorer.css b/static/explorer.css index eaa1783e..2be582b4 100644 --- a/static/explorer.css +++ b/static/explorer.css @@ -55,9 +55,33 @@ } .diff-picker { + max-width: 20em; width: 20em; } +.diff-picker .compiler { + font-weight: bold; +} + +.diff-picker .options { + padding-left: 0.5em; + font-size: small; +} + +.diff-picker .meta { + text-align: right; + list-style: none; + margin: 0; + padding: 0; + font-size: x-small; +} + +.diff-picker .meta li { + padding: 0; + display: inline; + margin: 0 10px 0 0; +} + input.options { width: 98%; margin-left: 0.25em; @@ -164,9 +188,9 @@ pre.content { } .font-option-active { - background: #226699!important; + background: #226699 !important; } .font-option-active:hover { - background: #4477AA!important; + background: #4477AA !important; } From 5f4638a2403ec3ee98b88f774e3a625255f9f00e Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sun, 26 Mar 2017 09:27:53 -0500 Subject: [PATCH 4/9] Defer removal of components. Can't remove components while others are being processed, else GL gets confused and misses out delivering messages to some. Also disposes editors, and makes sure output windows are closed when their parent is closed. Fixes #347 --- static/compiler.js | 7 ++++++- static/diff.js | 1 + static/output.js | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/static/compiler.js b/static/compiler.js index 5c64fe6f..983fdfc0 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -130,6 +130,7 @@ define(function (require) { container.on('destroy', function () { self.eventHub.unsubscribe(); self.eventHub.emit('compilerClose', self.id); + self.outputEditor.dispose(); }, this); container.on('resize', this.resize, this); container.on('shown', this.resize, this); @@ -448,7 +449,11 @@ define(function (require) { Compiler.prototype.onEditorClose = function (editor) { if (editor === this.sourceEditorId) { - this.container.close(); + // We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over + // the hierarchy. We can't modify while it's being iterated over. + _.defer(function (self) { + self.container.close(); + }, this); } }; diff --git a/static/diff.js b/static/diff.js index 50f87c48..1e540a81 100644 --- a/static/diff.js +++ b/static/diff.js @@ -107,6 +107,7 @@ define(function (require) { this.container.on('destroy', function () { this.eventHub.unsubscribe(); + this.outputEditor.dispose(); }, this); container.on('resize', this.resize, this); container.on('shown', this.resize, this); diff --git a/static/output.js b/static/output.js index 0dd0d8da..156a9dc3 100644 --- a/static/output.js +++ b/static/output.js @@ -44,6 +44,7 @@ define(function (require) { this.eventHub.on('compileResult', this.onCompileResult, this); this.eventHub.emit('resendCompilation', this.compilerId); this.eventHub.on('compilerFontScale', this.onFontScale, this); + this.eventHub.on('compilerClose', this.onCompilerClose, this); this.updateCompilerName(); } @@ -88,6 +89,16 @@ define(function (require) { this.container.setTitle(name); }; + Output.prototype.onCompilerClose = function (id) { + if (id === this.compilerId) { + // We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over + // the hierarchy. We can't modify while it's being iterated over. + _.defer(function (self) { + self.container.close(); + }, this); + } + }; + return { Output: Output }; From 45d4db9c0ed413e7a5a118f9a51f7cd3d1c36d02 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Mon, 27 Mar 2017 17:35:15 -0500 Subject: [PATCH 5/9] Fix up embedded 'edit on' floater --- views/embed.pug | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/views/embed.pug b/views/embed.pug index c42ed040..cc3fa2b6 100644 --- a/views/embed.pug +++ b/views/embed.pug @@ -4,9 +4,7 @@ html(lang="en") include head.pug body.embedded a.float-link.link(href="/" target="_blank") - | Edit on - span.lanugage-name - | Compiler Explorer + | Edit on #{language} Compiler Explorer span.glyphicon.glyphicon-new-window br From 2625f4f4628a1b6a9697a26b0e57a6bae2be26fb Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Mon, 27 Mar 2017 21:03:29 -0500 Subject: [PATCH 6/9] Disable view cache for debugging --- Makefile | 2 +- app.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 52d2f914..afabfd56 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ clean: $(MAKE) -C c-preload clean run: prereqs - $(NODE) ./node_modules/.bin/supervisor -w app.js,lib,etc/config -e 'js|node|properties|pug' --exec $(NODE) -- ./app.js --language $(LANG) $(EXTRA_ARGS) + $(NODE) ./node_modules/.bin/supervisor -w app.js,lib,etc/config -e 'js|node|properties' --exec $(NODE) -- ./app.js --language $(LANG) $(EXTRA_ARGS) HASH := $(shell git rev-parse HEAD) dist: prereqs diff --git a/app.js b/app.js index 1f67afa3..b9773817 100755 --- a/app.js +++ b/app.js @@ -516,7 +516,6 @@ findCompilers() webServer .set('trust proxy', true) .set('view engine', 'pug') - .set('view cache', true) .use(morgan('combined', {stream: logger.stream})) .use(compression()) .get('/', function (req, res) { From 1049a40e81edd44633589855fa3ac4f3939e03f6 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Mon, 27 Mar 2017 21:26:57 -0500 Subject: [PATCH 7/9] Tweaks to settings; separate on/off from delay --- static/editor.js | 6 ++++-- static/settings.js | 10 ++++++++-- views/popups.pug | 32 +++++++++++++++++++------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/static/editor.js b/static/editor.js index 639485ab..2fbb80a3 100644 --- a/static/editor.js +++ b/static/editor.js @@ -242,8 +242,10 @@ define(function (require) { // * Turn off auto. // * edit code // * change compiler or compiler options (out of date code is used) - if (before.delayAfterChange !== after.delayAfterChange || !this.debouncedEmitChange) { - if (after.delayAfterChange) { + var bDac = before.compileOnChange ? before.delayAfterChange : 0; + var aDac = after.compileOnChange ? after.delayAfterChange : 0; + if (bDac !== aDac || !this.debouncedEmitChange) { + if (aDac) { this.debouncedEmitChange = _.debounce(_.bind(function () { this.maybeEmitChange(); }, this), after.delayAfterChange); diff --git a/static/settings.js b/static/settings.js index 272cb3b7..547b3d0c 100644 --- a/static/settings.js +++ b/static/settings.js @@ -108,11 +108,17 @@ define(function (require) { _.map(colour.schemes, function (scheme) { return {label: scheme.name, desc: scheme.desc}; })); - add(root.find('.slider'), 'delayAfterChange', 750, Slider, { + // Handle older settings + if (settings.delayAfterChange === 0) { + settings.delayAfterChange = 750; + settings.compileOnChange = false; + } + add(root.find('.compileOnChange'), 'compileOnChange', true, Checkbox); + add(root.find('.delay'), 'delayAfterChange', 750, Slider, { max: 3000, step: 250, + min: 250, formatter: function (x) { - if (x === 0) return "Disabled"; return (x / 1000.0).toFixed(2) + "s"; } }); diff --git a/views/popups.pug b/views/popups.pug index 8edab1e4..9bfa7685 100644 --- a/views/popups.pug +++ b/views/popups.pug @@ -57,33 +57,39 @@ button.close(type="button" data-dismiss="modal" aria-hidden="true") × h3.modal-title Compiler Explorer Settings .modal-body - div + .well.well-sm | These settings control how Compiler Explorer acts for you. They are not | preserved as part of shared URLs, and are persisted locally using browser | local storage. + .well.well-sm h4 Editor .form-group(role="group") - .form-control.checkbox + .checkbox label input.autoCloseBrackets(type="checkbox") | Automatically insert matching brackets and parentheses - .form-control Delay before compiling:  - b Disabled - .slider.slider-horizontal.delay - b 3s - .form-control.checkbox + div + .checkbox + label + input.compileOnChange(type="checkbox") + | Compile automatically when source changes + div Delay before compiling:  + b 0.25s  + .slider.slider-horizontal.delay + b  3s + .checkbox label input.hoverShowSource(type="checkbox") | Highlight linked code lines on hover + .well.well-sm h4 Compilation .form-group(role="group") - .form-control.checkbox + .checkbox label input.colourise(type="checkbox") - | Colourise lines so one can see how the source maps to the output - .form-control - label - | Colour scheme: - select.colourScheme + | Colourise lines to show how the source maps to the output + label + | Colour scheme: + select.colourScheme .modal-footer button.btn.btn-default(type="button" data-dismiss="modal") Close From ba7c1e588bc42d8d1c7b2b91a89cd1c27c9996ec Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Mon, 27 Mar 2017 21:40:46 -0500 Subject: [PATCH 8/9] Add a shortcut to toggle autocompile. Fixes #350 (hopefully this is good for @mknejp) --- static/editor.js | 12 ++++++++++++ static/main.js | 5 ++++- static/settings.js | 9 +++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/static/editor.js b/static/editor.js index 2fbb80a3..75bc0d6f 100644 --- a/static/editor.js +++ b/static/editor.js @@ -98,6 +98,18 @@ define(function (require) { }, this) }); + this.editor.addAction({ + id: 'toggleCompileOnChange', + label: 'Toggle compile on change', + keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.Enter], + keybindingContext: null, + run: _.bind(function () { + this.eventHub.emit('modifySettings', { + compileOnChange: !this.settings.compileOnChange + }); + }, this) + }); + function tryCompilerSelectLine(thisLineNumber) { _.each(self.asmByCompiler, function (asms, compilerId) { var targetLines = []; diff --git a/static/main.js b/static/main.js index ab197cef..ae0fac2d 100644 --- a/static/main.js +++ b/static/main.js @@ -79,7 +79,10 @@ define(function (require) { eventHub.emit('settingsChange', currentSettings); }); - settings($('#settings'), currentSettings, onChange); + var setSettings = settings($('#settings'), currentSettings, onChange); + eventHub.on('modifySettings', function (newSettings) { + setSettings(_.extend(currentSettings, newSettings)); + }); } function start() { diff --git a/static/settings.js b/static/settings.js index 547b3d0c..160c5b2d 100644 --- a/static/settings.js +++ b/static/settings.js @@ -124,8 +124,13 @@ define(function (require) { }); add(root.find('.hoverShowSource'), 'hoverShowSource', true, Checkbox); - onSettingsChange(settings); - onChange(settings); + function setSettings(settings) { + onSettingsChange(settings); + onChange(settings); + } + + setSettings(settings); + return setSettings; } return setupSettings; From 2e606422df5b93a4e2a0cb0c4b340515cbe2b448 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 28 Mar 2017 07:21:50 -0500 Subject: [PATCH 9/9] Fix up thanks. (good spot @RabsRincon) --- static/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/static/main.js b/static/main.js index ae0fac2d..b05bf5a6 100644 --- a/static/main.js +++ b/static/main.js @@ -65,6 +65,7 @@ define(function (require) { var Raven = require('raven-js'); var settings = require('./settings'); var local = require('./local'); + var Alert = require('./alert'); function setupSettings(eventHub) { var currentSettings = JSON.parse(local.get('settings', '{}')); @@ -181,6 +182,11 @@ define(function (require) { local.remove('gl'); window.location.reload(); }); + $('#thanks-to').click(function () { + $.get('thanks.html', function (result) { + new Alert().alert("Special thanks to", $(result)); + }); + }); } $(start);